Regex Basics
Literals, dots, and the core syntax every pattern builds on.
- regex basics
- regex dot
- character class
- alternation
- regex group
Regex Basics
Literals, dots, and the core syntax every pattern builds on.
Commands
| Command | What it does | |
|---|---|---|
abc | Literal match of abc | |
. | Any character except newline | |
\d \w \s | Digit, word char, whitespace | |
\D \W \S | Negated classes | |
| `a | b` | Alternation: a or b |
(abc) | Capturing group |
Example
\d{4}-\d{2}-\d{2} # date like 2026-10-11
FAQ
Do I need to escape dots in domains?
Yes - an unescaped dot matches anything, so write backslash-dot for literal dots in domains and IPs.
Which flavor should I learn first?
PCRE and JavaScript overlap most; always test in the target engine since lookbehind and unicode details differ.
Câu hỏi thường gặp
Do I need to escape dots in domains?
Yes - an unescaped dot matches anything, so write backslash-dot for literal dots in domains and IPs.
Which flavor should I learn first?
PCRE and JavaScript overlap most; always test in the target engine since lookbehind and unicode details differ.
Regex
Regex Character Classes
Brackets, ranges, and negation for precise character sets.
Regex Quantifiers
Repeat matchers: star, plus, ranges, and exact counts.
Regex Anchors and Boundaries
Pin patterns to string, line, and word edges.
Regex Groups and Capturing
Capture, name, and backreference parts of a match.