Hi i need to split a string into an array based on this "dynamic" separator:
String  1 String2
String2 Â 65Â String3
The number between the Â
it's variable... also the strings could contain Â
too, so 开发者_如何学JAVAa str_replace or an explode it's useless (for me)
$str = "String  1  ";
$result = preg_split('/ Â [\d]+Â /', $str);
print_r($result);
Array
(
[0] => String
[1] => Â
)
Explanation:
# Match the characters “ Â ” literally « Â »
# Match a single digit 0..9 «[\d]+»
# Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
# Match the characters “Â ” literally «Â »
精彩评论