PatternRegex

Find ALL-CAPS words

Flag words typed in ALL CAPS — genuine acronyms and accidental shouting alike — so you can review tone or pull out initialisms.

Last updated

Patterng
\b[A-Z]{2,}\b
Open in Regex Tester & Builder

Matches

  • Please send the NDA today
  • This is URGENT

Doesn’t match

  • A cat sat on the mat
  • The Cat Sat on a Mat

Why it’s written this way

\b[A-Z]{2,}\b requires at least two consecutive uppercase letters bounded by word boundaries on both sides, so it fires only on a whole word that is entirely capitalized, not a word that merely starts with one.

The {2,} lower bound is deliberate: a single capital letter, like the start of an ordinary sentence or a lone initial, doesn't count as shouting.

Edge cases to know

  • →It can't tell a genuine acronym like NDA or API from a sentence typed in all caps out of frustration — both look identical to the pattern.
  • →Digits break the match rather than being ignored: 'NASA2' does NOT match, because \b requires a word boundary and there isn't one between A and 2. Add [A-Z0-9] to the class if your acronyms carry numbers.
  • →Single capital letters are excluded by design, so an initial such as the J in 'J. Smith' never triggers a false positive.

Part by part

\b
Word boundaries at each end, so the match covers a whole word rather than the capitalised opening of a normal one.
[A-Z]{2,}
Two or more uppercase letters. The minimum of two is what excludes ordinary sentence capitalisation, which is a single capital.

Common mistakes

  • [A-Z]+

    One or more matches the first letter of every capitalised word, so a normal sentence returns a hit on each proper noun and at every full stop. Two is the smallest threshold that means anything.

    \b[A-Z]{2,}\b
  • [A-Z]{2,}

    Without boundaries the pattern matches inside camelCase and PascalCase identifiers, so parsing source code returns fragments of names rather than acronyms.

  • \b[A-Z0-9]{2,}\b

    Adding digits pulls in part numbers, version codes and identifiers, which drowns the acronyms you were looking for. It is the right pattern for a different question.

Questions

Does it distinguish acronyms from shouting?

No — HTTP and SHOUTING look identical to it. Length is a rough proxy: most acronyms are two to five letters, so filtering longer matches finds the shouting and leaves the abbreviations alone.

Will it match accented capitals?

No. The class is ASCII only, so É and Ü are skipped. Use \p{Lu} with the u flag if you need uppercase across scripts — the ASCII form is faster and adequate for English.

Does it match Roman numerals?

Yes, because they are uppercase letters — II, IV, XVIII and so on all qualify. In a document with numbered sections that can dominate the results, so consider excluding the common ones.

How do I find shouting in a whole sentence?

Look for several consecutive matches rather than individual ones, or measure the ratio of uppercase to total letters across a span. A single acronym is normal; three in a row usually is not. A ratio above roughly a third across a full sentence is a reliable signal, and it degrades gracefully on text that legitimately contains many abbreviations.

Related in Patterns