Regex to split camel case

前端 未结 12 1853
逝去的感伤
逝去的感伤 2020-11-28 23:31

I have a regular expression in JavaScript to split my camel case string at the upper-case letters using the following code (which I subsequently got from here):



        
12条回答
  •  心在旅途
    2020-11-29 00:00

    a = 'threeBlindMice'
    a.match(/[A-Z]?[a-z]+/g) // [ 'three', 'Blind', 'Mice' ]
    

    is the simplest way I've found, for simple camel/titlecase splitting.

提交回复
热议问题