Match a whole word rather than part of a longer word
Example input
\bcat\b
flag: g
text: cat scatter catExpected result
0: cat
12: catPut the pattern and sample text in their separate fields and enable the global flag. The two standalone instances match; the letters inside scatter do not. The indexes describe JavaScript string positions. Use a separate example containing punctuation and non-ASCII writing when those cases are part of the real input you intend to search.