Reference 2026-04-25
Regex Cheatsheet for 2026
Quick reference for regex patterns, flags, and tested examples.
Regex is the Swiss Army knife of string processing. The syntax is dense; this cheatsheet covers what you reach for daily.
Character Classes
|---------|---------|
\d\D\w\W\s\S.[abc][^abc][a-z]Quantifiers
|---------|---------|
*+?{n}{n,}{n,m}+?, *?Anchors
^— start of string (or line withmflag)$— end of string (or line withmflag)\b— word boundary\B— non-word boundary
Groups and References
(abc)— capture group(?:abc)— non-capturing(?— named captureabc) \1— backreference to group 1\k— backreference to named group
Lookarounds
(?=foo)— positive lookahead(?!foo)— negative lookahead(?<=foo)— positive lookbehind(? — negative lookbehind
Common Patterns
Email: ^[\w.+-]+@[\w-]+\.[\w.-]+$
URL (basic): https?://[\w.-]+(?:/[\w./?=&%-]*)?
IPv4: ^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)$
ISO date: ^\d{4}-\d{2}-\d{2}$
UUID v4: ^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$
Slug: ^[a-z0-9]+(?:-[a-z0-9]+)*$
Flags
|------|--------|
gimsuvyTips
- Test patterns interactively before deploying.
- Catastrophic backtracking is real: avoid
(a+)+. - Email regex perfection is impossible; validate by sending a confirmation.
Try patterns interactively in the [Regex Tester](https://sdk.is/regex-tester).