$str="Hello MotoBell RingsKing Speech";
如果前面存在小写字母,则需要将此字符串扩展为大写字母。
:
$splitted=array(
0=>"Hello Moto",
1=>"Bell Rings",
2=>"King Speech"
);
任何想法?
我尝试使用reg_ex,但不工作:
$pieces = preg_split('/(?=[A-ZА-Я])/u', $str, -1, PREG_SPLIT_NO_EMPTY);
var_dump(preg_split('/(?<=[a-z])(?=[A-Z])/', 'Hello MotoBell RingsKing Speech'))
// array(3) {
// [0]=>
// string(10) "Hello Moto"
// [1]=>
// string(10) "Bell Rings"
// [2]=>
// string(11) "King Speech"
// }