omg*_*omg 25 php regex string split
"something here ; and there, oh,that's all!"
我想分裂它;
和,
所以处理后应该得到:
something here
and there
oh
that's all!
Run Code Online (Sandbox Code Playgroud)
med*_*iev 37
<?php
$pattern = '/[;,]/';
$string = "something here ; and there, oh,that's all!";
echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
Run Code Online (Sandbox Code Playgroud)
更新了更新问题的答案:
<?php
$pattern = '/[\x{ff0c},]/u';
//$string = "something here ; and there, oh,that's all!";
$string = 'hei,nihao?a ';
echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>';
Run Code Online (Sandbox Code Playgroud)
Dev*_*tas 10
$result_array = preg_split( "/[;,]/", $starting_string );
Run Code Online (Sandbox Code Playgroud)