I need a pattern to match type words APPLE:orPEAR:
APPLE:
PEAR:
[A-Z][:]will match R:, but not the whole word, and thus gives me a lie when I try to match.
[A-Z][:]
R:
Does anyone help?
Just add a "quantifier":
/[A-Z]+:/
Note that you do not need a character class for a single character.
You want to combine one or more capital letters, which means that you need to use +. Also yours :should not be in the character class:
+
:
[A-Z]+:
\b[A-Z]+:? \b btw.
\b[A-Z]+:
\b
I'm new to regular expressions, but I think the best way to combine a word in all capital letters is to use
/\b[A-Z]+\b:/
This is more crudely applicable if you do not want to match the character :and do not allow to appleS:be a match
appleS:
you need to use the operator +to match all characters in the group
try with regex:
[A-Z]+\: