I need to split string with multiple possible delimiters
$output = preg_split( "/(\^|+)/", "54654561^uo_sgzg@zrgher.com" );
-> ("54654561", "uo_sgzg@zrgher.com")
$output = preg_split( "/(\^|+)/", "54654561+ghkkgzg@zrgher.com" );
-> ("54654561", "ghkkgzg@zrgher.com")
But this regex "/(\^|+)/"
fails: PHP Warning: preg_split(): Compilation failed: nothing to repeat at offset 3
for some reason, however it's based on this answer Php multiple delimiters in explode
this one is working $output = preg_split("/[\^|+]/", "54654561^MYMED_sgzg@zrgher.com" );
is it the right way to split with multiple delimiters?
edit : sorry I just realized it's working like this $output = preg_split("/(\^|\+)/", "54654561^MYMED_sgzg@zrgher.com" );