A regular expression pattern to match words in all the bulbs followed by a colon

I need a pattern to match type words APPLE:orPEAR:

[A-Z][:]will match R:, but not the whole word, and thus gives me a lie when I try to match.

Does anyone help?

+5
source share
5 answers

Just add a "quantifier":

/[A-Z]+:/

Note that you do not need a character class for a single character.

+3
source

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]+:

+6
source

\b[A-Z]+:? \b btw.

+4
source

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

+1
source

you need to use the operator +to match all characters in the group

try with regex:

[A-Z]+\:
0
source

All Articles