I want to split a string,
str = "splitMeIfYouCan";
What I want is,
['split','me','if','you','can']
So, first I made it to lowerCase using String.prototype.toLowerCase() then used String.prototype.split(). No doubt, it was a wrong way.
My code:
var str = "splitMeIfYouCan";
var splitStr = str.split(/[A-Z]/);
//then a for loop to make them lower Case
My Output:
[ 'split', 'e', 'f', 'ou', 'an' ]
What .split()
did is cut all Upper Case letters. But I need those letters. Do you have any suggestions?