Test JavaScript regular expressions
A regular expression, often shortened to regex, is a pattern for finding text. Enter the pattern itself without surrounding slash delimiters, choose the flags you need and paste test text. Matches update as the pattern, flags or text changes.
This tool uses the regular-expression engine built into JavaScript in your browser. JavaScript regex syntax and behaviour can differ from PCRE, Python, .NET, Java and PHP, so test a pattern in its destination language before relying on it there.
Find the whole word “cat”
Pattern: \bcat\b with the global (g) flag.
Text: The cat sat down. A category is not a cat.
Result: two matches; “category” is excluded by the word boundaries.