Text Processingflags: gi
Word Boundary (Whole Word Match)
Match the whole word `cat` without matching it inside other words like `concatenate` or `category`.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\bcat\b (flags: gi)Raw source: \bcat\b
How it works
\b is a zero-width assertion at a word boundary — the position between a word character (\w) and a non-word character (or string edge). Wrapping `cat` in two \b anchors forces the match to start AND end at word boundaries, so `cat` matches but `concat` and `cats` do not.
Examples
Input
The cat sat on the mat.Matches
cat
Input
I will concatenate the strings.No match
—Input
CAT, Cat, cat — all match.Matches
CATCatcat
Common use cases
- •Find-and-replace targeting whole words only
- •Search-engine-style keyword highlighting
- •Linting for forbidden whole-word identifiers
- •Tokenizer fallback in NLP pipelines