(TO THE GOD OF ABRAHAM, ISAAC AND JACOB. I DEDICATE THIS WORK TO YOU MAY YOU BLESS IT AND MAY IT BLESS THOSE YOU USE IT, MORESO MAY THEY KNOW YOU BY NAME, REPENT AND BE LED TO YOUR WILL AND KINGDOM.) Our Father who is in the heavens, let Your Name be set-apart,let Your reign come, let Your desire be done on earth as it is in heaven. Give us today our daily bread. And forgive us our debts, as we for- give our debtors. And do not lead us into trial, but deliver us from the wicked one because Yours is the reign and the power and the esteem, forever. Amen.
Regex Cheat Sheet: Quick Reference for Regular Expressions | devformat.tools Blog
regexreferencecheat-sheet

Regex Cheat Sheet: Quick Reference for Regular Expressions

A quick reference cheat sheet for regular expressions. Covers syntax, character classes, quantifiers, groups, lookaheads, and common patterns with examples.

By devformat.tools · · 4 min read

Regex Cheat Sheet: Quick Reference for Regular Expressions

Regular expressions (regex) are powerful but notoriously hard to remember. This cheat sheet covers the most common regex syntax with practical examples you can copy and use.

Basic Syntax

Pattern Description Example Matches
. Any character (except newline) h.t hat, hit, hot
\d Any digit [0-9] \d{3} 123, 456
\D Any non-digit \D+ abc, xyz
\w Word character [a-zA-Z0-9_] \w+ hello_world
\W Non-word character \W @, #, !
\s Whitespace (space, tab, newline) \s+ spaces/tabs
\S Non-whitespace \S+ words
\b Word boundary \bcat\b "cat" but not "catch"

Quantifiers

Pattern Description Example Matches
* 0 or more ab*c ac, abc, abbc
+ 1 or more ab+c abc, abbc (not ac)
? 0 or 1 colou?r color, colour
{n} Exactly n \d{4} 2024, 1999
{n,} n or more \d{2,} 42, 123, 9999
{n,m} Between n and m \d{2,4} 42, 123, 9999
*? 0 or more (lazy) ".*?" shortest match
+? 1 or more (lazy) <.+?> single HTML tag

Character Classes

Pattern Description Example
[abc] a, b, or c [aeiou] matches vowels
[^abc] Not a, b, or c [^0-9] matches non-digits
[a-z] Range: a through z [A-Za-z] matches letters
[0-9] Range: 0 through 9 Same as \d

Anchors

Pattern Description Example Matches
^ Start of string/line ^Hello "Hello world" (start)
$ End of string/line world$ "Hello world" (end)
\b Word boundary \bthe\b "the" not "them"

Groups and References

Pattern Description Example
(abc) Capture group (\d{3})-(\d{4}) captures area code and number
(?:abc) Non-capturing group `(?:http
\1 Back-reference to group 1 (\w+)\s\1 matches "the the"
(?<name>abc) Named capture group (?<year>\d{4})

Lookahead and Lookbehind

Pattern Description Example Matches
(?=abc) Positive lookahead \d(?=px) "5" in "5px"
(?!abc) Negative lookahead \d(?!px) "5" in "5em"
(?<=abc) Positive lookbehind (?<=\$)\d+ "100" in "$100"
(?<!abc) Negative lookbehind (?<!\$)\d+ "100" in "100"

Flags

Flag Description
g Global — find all matches, not just the first
i Case-insensitive
m Multiline — ^ and $ match line boundaries
s Dotall — . matches newlines too
u Unicode support

Common Patterns

Email (simplified)

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

URL

https?://[^\s/$.?#].[^\s]*

IP Address (IPv4)

\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b

Phone Number (US)

(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}

Date (YYYY-MM-DD)

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])

Hex Color

#(?:[0-9a-fA-F]{3}){1,2}\b

Strong Password (8+ chars, upper, lower, digit, special)

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

HTML Tag

<([a-z][a-z0-9]*)\b[^>]*>(.*?)</\1>

Trim Whitespace

^\s+|\s+$

Test Your Regex

Build and test regular expressions with live matching:

Regex Tester →

Our regex tester runs entirely in your browser — your test data stays private.


Test and debug regex patterns with devformat.tools Regex Tester — live matching, group capture, zero data collection.

Try our free developer tools

51+ tools that run in your browser. No data sent anywhere.

Browse Tools