IT-tools

Regex cheatsheet

A regex cheatsheet covering characters, anchors, quantifiers, groups, lookarounds, and common patterns. Copy examples as needed.

Characters
Any character.
Digit\d
Word character\w
Whitespace\s
Not a digit\D
Anchors & boundaries
Start of string^
End of string$
Word boundary\b
Non-word boundary\B
Quantifiers
Zero or more*
One or more+
Zero or one?
Exactly n{n}
Between n and m{n,m}
Lazy match*?
Groups
Capturing group(...)
Non-capturing group(?:...)
Named group(?<name>...)
Backreference\1
Alternationa|b
Lookarounds
Positive lookahead(?=...)
Negative lookahead(?!...)
Positive lookbehind(?<=...)
Negative lookbehind(?<!...)

// About this tool

Look up regex syntax without searching through documentation. Browse categories and copy the expression or pattern you need into your code. Each entry includes a short description.

// How to use it

  1. Find the syntax category you need.
  2. Review the expression and description.
  3. Copy the pattern into your code.

// Frequently asked questions

Which regex flavor is this for?

The examples follow common JavaScript/PCRE-style syntax; some engines differ in details.

Does it test patterns?

No. Use the regex tester tool to run a pattern against sample text.