FreeDev Tools

Regex Cheatsheet

Quick reference for regular expression syntax, flags, and common patterns.

Anchors

^Start of string
$End of string
\bWord boundary
\BNon-word boundary

Character Classes

.Any character except newline
\dDigit [0-9]
\DNon-digit
\wWord char [a-zA-Z0-9_]
\WNon-word char
\sWhitespace
\SNon-whitespace

Quantifiers

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

Groups

(abc)Capture group
(?:abc)Non-capture group
(?<name>)Named capture
\1Backreference group 1
(?=abc)Positive lookahead
(?!abc)Negative lookahead

Sets

[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Range a through z
[a-zA-Z]Any letter

Flags

gGlobal (all matches)
iCase-insensitive
mMultiline (^ and $ per line)
sDot matches newline
uUnicode mode

Common Patterns

\d{4}-\d{2}-\d{2}Date YYYY-MM-DD
[\w.-]+@[\w.-]+\.\w+Email (simple)
https?:\/\/\S+URL
\b\d{1,3}(\.\d{1,3}){3}\bIPv4 address

Frequently Asked Questions

The cheat sheet covers JavaScript/ECMAScript regex syntax, which is also largely compatible with Python, Java, and most modern languages.