11 chars · 1 line
8 chars · 1 line
11 chars · 1 line
8 chars · 1 line
Regex boundary behavior
The valid pattern cat matches the substring inside concatenate. When cat should count only as a standalone word, add \b boundaries around the token. This tool is free to use. No account or payment is required.
Last updated
\b checks the transition between word and non-word characters. It can therefore find a standalone word inside a sentence, while ^ and $ are used when boundaries belong to the whole input or line.
Prevent cat from matching inside concatenate while still allowing the standalone word cat.
cat\bcat\bCommon questions
Because a regex without boundaries can match the cat substring at any position.
In regex pattern syntax, \b outside a character class represents a word boundary.
JavaScript word-boundary behavior is based on regex word-character rules, so language-specific tokenization can require a different pattern.
Debugging a specific Regex issue? Browse Regex troubleshooting.