Regex Cheatsheet

Browse every regex token with a live example you can click to test instantly.

Regex Cheatsheet

Character Classes

`.`Any char except newline
`\w`Word char [a-zA-Z0-9_]
`\d`Digit [0-9]
`\s`Whitespace
`\W \D \S`Negated versions
`[abc]`Any of a, b, c
`[^abc]`Not a, b, or c
`[a-z]`Range

Anchors

`^`Start of string
`$`End of string
`\b`Word boundary
`\B`Non-word boundary

Quantifiers

`*`0 or more
`+`1 or more
`?`0 or 1
`{n}`Exactly n
`{n,}`n or more
`{n,m}`Between n and m
`*? +? ??`Lazy (non-greedy)

Groups

`(abc)`Capture group
`(?:abc)`Non-capture group
`(?=abc)`Positive lookahead
`(?!abc)`Negative lookahead
`a|b`Alternation

Summary

Browse every regex token with a live example you can click to test instantly.

How it works

  1. Browse categories: anchors, groups, quantifiers
  2. Click any token to open a live example
  3. Edit the example to explore variations

Use cases

  • Quick reference while writing patterns
  • Teaching regex in workshops
  • Remembering obscure lookahead syntax

Frequently Asked Questions

Last updated: 2026-06-09 · Reviewed by Nham Vu