Regular Expression Pattern to Match Words in All Caps That Are Followed By a colon
You want to match one or more capital letter which means you need to use a +
. Also your :
doesn't need to be in a character class:
[A-Z]+:
Just add a "quantifier":
/[A-Z]+:/
Note you don't need a character class for a single character.
How about \b[A-Z]+:
? The \b
is for checking a word boundary btw.