How do I find and extract capitalized words of a string with regex?
I would like to:
- extract the capitalized words of a string, as an array
- extract the last capitalized word of a string, as a substring:
Both with one regex
If I have this:
var str="This is a STRING of WORDS to search";
I would like to get this 1:
allCapWords // = ["STRING", "WORDS"]
and 2:
lastCapWord // = "WORDS"