I have camel cased strings like this:
"numberOf40"
"numberOf40hc"
How can I split it like this?
["number", "Of", "40"]
["number", "Of", "40hc"]
I am using humps to decamelize keys so I can only pass a split
regex as option. I am looking for an answer that only uses split
function.
My best attempts:
const a = "numberOf40hc"
a.split(/(?=[A-Z0-9])/)
// ["number", "Of", "4", "0hc"]
a.split(/(?=[A-Z])|[^0-9](?=[0-9])/)
// ["number", "O", "40hc"]
Also I don't understand why the f
is omitted in my last attempt.