I need a regular expression that gets a word only if every letter is capitalized (this also includes underscores).
Heres the code im using now. /\b[A-Z_]+/g
“This IS a NEW_SENTENCE to HELP_EXplain my PROblem.”
In the above sentence all the letters that are capitalized will be selected. Even if they are apart of a word that has lowercase letters. How can i fix my code so only words with all capital letters and / or underscores are selected? (In this case from the sentence above, ‘IS’ and ‘NEW_SENTENCE’ should be the only words selected.)
With a word boundary (
\b):This will match words with only capital letters and
_.It matches
IS,NEW_SENTENCE, and NOTHELP_EXplain,PROblem.The
\bmatches positions that are preceeded by a non-word character and followed by a word character (and the inverse).