I need to split string with multiple possible delimiters
$output = preg_split( "/(\^|+)/", "54654561^[email protected]" );
-> ("54654561", "[email protected]")
$output = preg_split( "/(\^|+)/", "[email protected]" );
-> ("54654561", "[email protected]")
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^[email protected]" );
is it the right way to split with multiple delimiters?
edit : sorry I just realized it's working like this $output = preg_split("/(\^|\+)/", "54654561^[email protected]" );