我需要用多个可能的分隔符分割字符串
$output = preg_split( "/(\^|+)/", "54654561^uo_sgzg@zrgher.com" );
->(“54654561”,“uo_sgzg@zrgher.com”)
$output = preg_split( "/(\^|+)/", "54654561+ghkkgzg@zrgher.com" );
-> ("54654561", "ghkkgzg@zrgher.com")
但是这个正则表达式"/(\^|+)/"
失败了:PHP Warning: preg_split(): Compilation failed: nothing to repeat at offset 3
出于某种原因,但是它基于这个答案Php multiple delimiters in explode
这个正在工作$output = preg_split("/[\^|+]/", "54654561^MYMED_sgzg@zrgher.com" );
是用多个分隔符分割的正确方法吗?
编辑:对不起,我刚刚意识到它是这样工作的$output = preg_split("/(\^|\+)/", "54654561^MYMED_sgzg@zrgher.com" );