How can I use a regular expression to match a word or groups of words that are in capital letters?
I believe that I solved the problem halfway, although this may not be the case.
I try to catch one word in all caps, or two or three - basically, if they are in a row, I want them to be captured as a group, and not as every word.
eg.:
"HAPPY BIRTHDAY TOMMY" does not match and returns [0] -> HAPPY, [1] -> BIRTHDAY, [2] -> TOMMY , and the whole group, for example [0] -> HAPPY BIRTHDAY TOMMY .
The code I use below matches βHAPPY BIRTHDAYβ together, or just βTOMMYβ, but not all together.
[AZ]{1,}\s[AZ]{1,}|\b[AZ]{1,}\b
source share