# What \b matches

`/\bcat\b/`

**Match a word boundary, then "c", then "a", then "t", then a word boundary.**

## Step by step

- `\b` — Anchor to a word boundary.
- `c` — Match "c".
- `a` — Match "a".
- `t` — Match "t".
- `\b` — Anchor to a word boundary.

## Warnings

### Unanchored — matches anywhere in the input (caution)

Without ^ and $ the pattern succeeds if it matches ANY substring. A validator meant to check a whole value will therefore accept anything that merely contains a valid value: an email pattern without anchors accepts "nonsense a@b.co nonsense".

**Fix:** Wrap the pattern in ^ and $ if it is validating a whole string. Leave it unanchored only if you are genuinely searching within text.

## Details

- Capture groups: none

---

Canonical URL: https://regex-explainer.gumballtools.com/regex/word-boundary-regex
JSON API: `GET https://regex-explainer.gumballtools.com/api/v1/explain?pattern=...`
MCP endpoint: `https://regex-explainer.gumballtools.com/api/mcp`
