How can I add a space in string at capital letters, but keep continuous capitals together using PHP and a Regex?

前端 未结 1 1913
鱼传尺愫
鱼传尺愫 2021-02-04 07:41

I want to add a space to a string on capital letters using a PHP method like preg_replace() and a regex, but I only want to add a space on the first capital letter

相关标签:
1条回答
  • Find:

    (?<!^)((?<![[:upper:]])[[:upper:]]|[[:upper:]](?![[:upper:]]))
    

    Replace:

     $1
    

    note the space before $1

    Edit: fix.

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