Regex Cheat Sheet
Complete regular expression quick reference with character classes, quantifiers, anchors, groups, lookaheads, flags, and common patterns. Click any pattern to copy.
Character Classes
| Pattern | Description | Example | |
|---|---|---|---|
. | Any character except newline | a.c matches "abc", "a1c" | |
\d | Any digit [0-9] | \d{3} matches "123" | |
\D | Any non-digit [^0-9] | \D+ matches "abc" | |
\w | Any word character [a-zA-Z0-9_] | \w+ matches "hello_1" | |
\W | Any non-word character [^a-zA-Z0-9_] | \W matches "@" | |
\s | Any whitespace (space, tab, newline) | a\sb matches "a b" | |
\S | Any non-whitespace character | \S+ matches "hello" | |
[abc] | Any one of a, b, or c | [aeiou] matches vowels | |
[^abc] | Any character except a, b, or c | [^0-9] matches non-digits | |
[a-z] | Any lowercase letter | [a-z]+ matches "hello" | |
[A-Z] | Any uppercase letter | [A-Z] matches "H" | |
[0-9] | Any digit (same as \d) | [0-9]{2} matches "42" |
.Any character except newline
a.c matches "abc", "a1c"
\dAny digit [0-9]
\d{3} matches "123"
\DAny non-digit [^0-9]
\D+ matches "abc"
\wAny word character [a-zA-Z0-9_]
\w+ matches "hello_1"
\WAny non-word character [^a-zA-Z0-9_]
\W matches "@"
\sAny whitespace (space, tab, newline)
a\sb matches "a b"
\SAny non-whitespace character
\S+ matches "hello"
[abc]Any one of a, b, or c
[aeiou] matches vowels
[^abc]Any character except a, b, or c
[^0-9] matches non-digits
[a-z]Any lowercase letter
[a-z]+ matches "hello"
[A-Z]Any uppercase letter
[A-Z] matches "H"
[0-9]Any digit (same as \d)
[0-9]{2} matches "42"
Quantifiers
| Pattern | Description | Example | |
|---|---|---|---|
* | 0 or more times (greedy) | ab*c matches "ac", "abc", "abbc" | |
+ | 1 or more times (greedy) | ab+c matches "abc", "abbc" | |
? | 0 or 1 time (optional) | colou?r matches "color", "colour" | |
{n} | Exactly n times | \d{4} matches "2024" | |
{n,} | n or more times | \w{3,} matches 3+ word chars | |
{n,m} | Between n and m times | \d{2,4} matches "12", "1234" | |
*? | 0 or more times (lazy) | <.*?> matches first tag only | |
+? | 1 or more times (lazy) | \w+? matches single char | |
?? | 0 or 1 time (lazy) | \d?? prefers 0 digits |
*0 or more times (greedy)
ab*c matches "ac", "abc", "abbc"
+1 or more times (greedy)
ab+c matches "abc", "abbc"
?0 or 1 time (optional)
colou?r matches "color", "colour"
{n}Exactly n times
\d{4} matches "2024"
{n,}n or more times
\w{3,} matches 3+ word chars
{n,m}Between n and m times
\d{2,4} matches "12", "1234"
*?0 or more times (lazy)
<.*?> matches first tag only
+?1 or more times (lazy)
\w+? matches single char
??0 or 1 time (lazy)
\d?? prefers 0 digits
Anchors & Boundaries
| Pattern | Description | Example | |
|---|---|---|---|
^ | Start of string (or line in multiline mode) | ^Hello matches "Hello world" | |
$ | End of string (or line in multiline mode) | world$ matches "Hello world" | |
\b | Word boundary | \bcat\b matches "cat" not "catch" | |
\B | Non-word boundary | \Bcat matches "scat" not "cat" |
^Start of string (or line in multiline mode)
^Hello matches "Hello world"
$End of string (or line in multiline mode)
world$ matches "Hello world"
\bWord boundary
\bcat\b matches "cat" not "catch"
\BNon-word boundary
\Bcat matches "scat" not "cat"
Groups & Backreferences
| Pattern | Description | Example | |
|---|---|---|---|
(abc) | Capturing group | (\d+)-(\d+) captures both numbers | |
(?:abc) | Non-capturing group | (?:ab)+ matches "abab" | |
(?<name>abc) | Named capturing group | (?<year>\d{4}) captures as 'year' | |
\1 | Backreference to group 1 | (\w)\1 matches "aa", "bb" | |
(?=abc) | Positive lookahead | \d(?=px) matches "5" in "5px" | |
(?!abc) | Negative lookahead | \d(?!px) matches "5" in "5em" | |
(?<=abc) | Positive lookbehind | (?<=\$)\d+ matches "50" in "$50" | |
(?<!abc) | Negative lookbehind | (?<!\$)\d+ matches "50" in "50" |
(abc)Capturing group
(\d+)-(\d+) captures both numbers
(?:abc)Non-capturing group
(?:ab)+ matches "abab"
(?<name>abc)Named capturing group
(?<year>\d{4}) captures as 'year'
\1Backreference to group 1
(\w)\1 matches "aa", "bb"
(?=abc)Positive lookahead
\d(?=px) matches "5" in "5px"
(?!abc)Negative lookahead
\d(?!px) matches "5" in "5em"
(?<=abc)Positive lookbehind
(?<=\$)\d+ matches "50" in "$50"
(?<!abc)Negative lookbehind
(?<!\$)\d+ matches "50" in "50"
Flags
| Pattern | Description | Example | |
|---|---|---|---|
g | Global: find all matches, not just the first | /cat/g matches all "cat" occurrences | |
i | Case insensitive: ignore upper/lowercase | /hello/i matches "HELLO" | |
m | Multiline: ^ and $ match line boundaries | /^line/m matches each line start | |
s | Dotall: . matches newline characters too | /a.b/s matches "a\nb" | |
u | Unicode: enable full Unicode matching | /\u{1F600}/u matches emoji | |
y | Sticky: match only from lastIndex position | /\d/y matches at exact position |
gGlobal: find all matches, not just the first
/cat/g matches all "cat" occurrences
iCase insensitive: ignore upper/lowercase
/hello/i matches "HELLO"
mMultiline: ^ and $ match line boundaries
/^line/m matches each line start
sDotall: . matches newline characters too
/a.b/s matches "a\nb"
uUnicode: enable full Unicode matching
/\u{1F600}/u matches emoji
ySticky: match only from lastIndex position
/\d/y matches at exact position
Common Patterns
| Pattern | Description | Example | |
|---|---|---|---|
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | Email address | user@example.com | |
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*) | URL | https://www.example.com/path?q=1 | |
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b | IPv4 address | 192.168.1.1 | |
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) | Date (YYYY-MM-DD) | 2024-12-31 | |
#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3}) | Hex color code | #ff6600 or #f60 | |
<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1> | HTML tag with content | <div>content</div> | |
\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9} | Phone number (international) | +1 (555) 123-4567 |
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Email address
user@example.com
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)URL
https://www.example.com/path?q=1
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bIPv4 address
192.168.1.1
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])Date (YYYY-MM-DD)
2024-12-31
#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})Hex color code
#ff6600 or #f60
<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>HTML tag with content
<div>content</div>
\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}Phone number (international)
+1 (555) 123-4567
About This Tool
The Regex Cheat Sheet is a free online tool available on CodeUtilo. Quick reference for regular expressions. Character classes, quantifiers, groups, and common patterns. All processing happens directly in your browser — no data is ever sent to any server, ensuring your privacy and security. No signup or installation is required.
Key Features
- Browser-Based Processing — All regex cheat sheet operations run locally in your browser using JavaScript. Your data never leaves your device.
- Instant Results — Get results immediately as you type or paste your input. No waiting for server responses or page reloads.
- Free & No Signup — Use the regex cheat sheet as many times as you need without creating an account or paying anything.
- Mobile Friendly — Works on desktop, tablet, and mobile browsers. Access this tool from any device with an internet connection.
Common Use Cases
- Using the regex cheat sheet for day-to-day development tasks
- Saving time on repetitive tasks by using a browser-based tool instead of writing custom code
- Working on projects where installing software is not an option (school, work, shared computers)
- Quick prototyping and debugging without switching to a terminal or IDE
- Sharing the tool link with colleagues who need the same functionality
How to Use
Enter your input in the text area provided and the regex cheat sheet will process it instantly. Use the Copy button to copy the result to your clipboard. All operations are performed locally in your browser — no data is transmitted to any server.
Frequently Asked Questions
Is the Regex Cheat Sheet free to use?
Yes, the Regex Cheat Sheet is completely free with no usage limits. There is no signup or registration required. You can use it as many times as you need.
Is my data safe when using this tool?
Yes. All processing happens locally in your browser using JavaScript. Your data is never uploaded to any server or stored anywhere. Everything stays on your device.
Does this tool work on mobile devices?
Yes. The Regex Cheat Sheet is fully responsive and works on smartphones, tablets, and desktop computers. You can use it from any modern browser on any device.
Do I need to install anything?
No. The Regex Cheat Sheet runs entirely in your web browser. There is nothing to download or install. Just open the page and start using it immediately.
Related Tools
Workflow Links
Suggested step-by-step tools based on this page intent.
Before This Tool