Developer Reference

Regular Expressions Cheat Sheet

Regular expression syntax reference for character classes, anchors, quantifiers, and lookaround. Free, in-browser cheat sheet.

Regular expressions are a powerful tool for pattern matching and text processing across most programming languages. This reference covers the core syntax you need to construct patterns for validation, extraction, and transformation—from basic character classes to advanced lookahead and lookbehind assertions.

Character classes

TokenMatches
.Any character except newline
\dAny digit (0-9)
\DAny non-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace
\SNon-whitespace
[abc]a, b, or c
[^abc]Not a, b, or c
[a-z]Range a to z

Anchors & quantifiers

TokenMatches
^Start of string / line
$End of string / line
\bWord boundary
*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m
*?Lazy 0 or more

Groups & lookaround

TokenMatches
(abc)Capture group
(?:abc)Non-capturing group
(?<name>abc)Named group
a|ba or b (alternation)
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
\1Backreference to group 1

How this reference is used

  • Validating email addresses or phone numbers in a form
  • Extracting data like dates or URLs from unstructured text
  • Finding and replacing patterns in code or configuration files
  • Testing string patterns during development or debugging
  • Learning regex syntax for a new language or framework

Frequently asked questions

What is the difference between a character class and a character range?

A character class like [abc] matches any single character from the set. A range like [a-z] matches any character within that span. Both are shorthand for avoiding verbose alternation and make patterns more readable.

When should I use anchors like ^ and $ in my patterns?

Anchors tie your pattern to specific positions in the string. Use ^ and $ to match from the start and end respectively, preventing partial matches when you need the entire string to conform to your pattern.

How do lookahead and lookbehind assertions differ from capturing groups?

Lookahead and lookbehind assertions (like (?=...) and (?<=...)) check if a pattern exists without consuming characters or being captured. Capturing groups ((...)) extract matched text. Use assertions for conditional matching without side effects.

More developer references

FreeToolz Editorial Team · Last reviewed July 2026

Compiled and checked against the relevant standards. Free to use and reference — this page runs entirely in your browser.