It works for me halfway. This works great:
'MyOwnVar'.match(/([a-z]*)([A-Z][a-z]+)/g)
Result:
["My", "Own", "Var"]
The goal is to pull out individual words. But if I give it the name camelCase:
'MyOwnVar'.match(/([a-z]*)([A-Z][a-z]+)/g)
I get:
["myOwn", "Var"]
I cannot understand what I am doing wrong. As far as I can tell, two sets ()
should store the matching results in two separate elements of the array. For some reason, they bring them together.
source
share