php explode string with Uppercase if lowercase letter exists before it without space

前端 未结 1 437
闹比i
闹比i 2021-01-15 04:11
$str=\"Hello MotoBell RingsKing Speech\";

I need explode this string by uppercase letter if lowercase letter exists before it.

like this:

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-15 04:42

    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"
    // }
    

    0 讨论(0)
提交回复
热议问题