Try though I may, can’t figure out how to use regex in javascript to get an array of words (assuming all words are capitalized). For example:
Given this: NowIsAGoodTime
How can you use regex to get: [‘Now’,’Is’,’A’,’Good’,’Time’]
Thanks Very Much!!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
[A-Z],[a-z]and[0-9]are character sets defined as ranges. They could be[b-xï], for instance (from “b” to “x” plus “ï”).String.prototype.matchalways returns an array ornullif no match at all.Finally, the
gregexp flag stands for “global match”. It means, it will try to match the same pattern on subsequent string parts. By default (with nogflag), it will be satisfied with the first match.With a globally matching regexp,
matchreturns an array of matching substrings.With single match regexps, it would return the substring matched to the whole pattern, followed by the pattern groups matches. E. g.:
See more on
Regexp.