Regex Anchors and Boundaries
Pin patterns to string, line, and word edges.
- regex anchor
- word boundary
- multiline flag
- match whole string
- caret dollar
Regex Anchors and Boundaries
Pin patterns to string, line, and word edges.
Commands
| Command | What it does |
|---|---|
^abc | Start of string or line |
xyz$ | End of string or line |
\bword\b | Whole word only |
\B | Not a word boundary |
^...$ with m flag | Per-line anchors |
Example
\berror\b # matches error, not errors
FAQ
How do caret and dollar behave with multiline?
Without the m flag they anchor the whole string; with m they anchor each line.
How do I match a whole input exactly?
Wrap as start-group-end so partial matches cannot slip through validation.
SSS
How do caret and dollar behave with multiline?
Without the m flag they anchor the whole string; with m they anchor each line.
How do I match a whole input exactly?
Wrap as start-group-end so partial matches cannot slip through validation.
Regex
Regex Basics
Literals, dots, and the core syntax every pattern builds on.
Regex Character Classes
Brackets, ranges, and negation for precise character sets.
Regex Quantifiers
Repeat matchers: star, plus, ranges, and exact counts.
Regex Groups and Capturing
Capture, name, and backreference parts of a match.