Loading…
Quick regex syntax cheatsheet with examples. Use when looking up syntax; for live testing use regex-tester. Input: search text. Returns pattern snippets. 100% client-side.
Regex Cheatsheet is loading — interactive editor will appear here. Use examples below to try instantly once loaded.
Press ? for keyboard shortcuts
Interactive regular expression reference covering character classes, quantifiers, anchors, groups, lookaheads, and flags with real-world examples. Each pattern includes a description, example input/output, and common use cases.
Regular expressions are powerful but notoriously difficult to memorize. This interactive cheatsheet provides instant access to every regex concept with practical examples, eliminating the need to search external documentation.
This tool is part of the DevStackIO platform — a collection of free online developer tools from DevStackIO. Browse more free developer resources on DevStackIO.
Developers writing or debugging regex patterns, data analysts building data extraction pipelines, QA engineers validating input formats, and students learning regular expressions.
Browse regex patterns by category: Character Classes, Quantifiers, Anchors, Groups, Lookarounds, Flags
Click on any pattern to expand its description and examples
Use the copy button to copy the regex snippet to your clipboard
Read the example input/output to understand how each pattern behaves
Combine patterns by referencing multiple sections for complex regex construction
Category: Character Classes. Pattern: \d matches digits, \w matches word characters, \s matches whitespace. Example: \d{3}-\d{4} matches '555-1234'.Category: Lookarounds. Pattern: (?=...) positive lookahead. Example: \w+(?=@) matches 'user' in 'user@email.com' without including the @ symbol.What's the difference between * and +?
* matches zero or more (can match nothing), + matches one or more (must match at least once).
When should I use the 'g' (global) flag?
Use it when you want to find all matches in a string, not just the first one.
How do I match literal special characters?
Escape them with a backslash: \. matches a literal dot.
Can regex match HTML?
Technically yes, but it's fragile and not recommended. Use a proper HTML parser instead.
Authoritative specifications, standards, and in-depth reading for Regex Cheatsheet.
Tool is loading — interactive editor will appear here. Use examples below to try instantly once loaded.
Test and debug regular expressions with live matching and capture groups. Paste pattern and sample text.
Search common git commands with examples. Use as quick reference; for regex help use regex-memo. Input: search text. Returns command snippets. 100% client-side.
Find JSONPath expressions by clicking any key. Use when querying APIs; for formatting use json-formatter. Input: JSON ≤10MB. Returns matching paths and values. 100% client-side.
Look up MIME types by extension and vice versa. Use when configuring uploads; for file checksums use file-checksum. Input: extension or MIME. Returns MIME mapping. 100% client-side.
Calculate chmod permissions from checkboxes or octal. Use when setting file modes; for git perms use git-cheatsheet. Input: mode or ticks. Returns octal and symbolic. 100% client-side.
Analyze cyclomatic complexity and code metrics. Use when reviewing quality; for formatting use js-minifier. Input: code ≤10MB. Returns complexity scores. 100% client-side.
Show key code and key name for any pressed key. Use when debugging shortcuts; for regex keys use regex-tester. Input: key press. Returns code details. 100% client-side.
Find and replace text with literal, regex, and case-insensitive modes. Shows replacement count.
Learn the concepts behind this tool.
Browse all glossary terms.Any character except newline
\wWord character (a-z, A-Z, 0-9, _)
\w+ matches 'hello_123'
\WNon-word character
\dDigit (0-9)
\d{3} matches '123'
\DNon-digit
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Match a, b, or c
[aeiou] matches any vowel
[^abc]Not a, b, or c
[^0-9] matches non-digits
[a-z]Range: a to z
[A-Za-z] matches any letter
*Zero or more
ab*c matches 'ac', 'abc', 'abbc'
+One or more
ab+c matches 'abc', 'abbc' (not 'ac')
?Zero or one (optional)
colou?r matches 'color' and 'colour'
{n}Exactly n times
\d{4} matches '2024'
{n,}n or more times
{n,m}Between n and m times
\d{2,4} matches '12', '123', '1234'
*?Zero or more (lazy/non-greedy)
+?One or more (lazy/non-greedy)
^Start of string/line
^Hello matches 'Hello World'
$End of string/line
world$ matches 'Hello world'
\bWord boundary
\bcat\b matches 'cat' in 'the cat sat'
\BNon-word boundary
(abc)Capture group
(\d{3})-(\d{4}) captures area code
(?:abc)Non-capturing group
(?<name>abc)Named capture group
(?<year>\d{4})
a|bAlternation (a or b)
cat|dog matches 'cat' or 'dog'
\1Backreference to group 1
(?=abc)Positive lookahead
\d(?=px) matches '5' in '5px'
(?!abc)Negative lookahead
\d(?!px) matches '5' in '5em'
(?<=abc)Positive lookbehind
(?<=\$)\d+ matches '100' in '$100'
(?<!abc)Negative lookbehind
gGlobal: match all occurrences
iCase-insensitive matching
mMultiline: ^ and $ match line boundaries
sDotall: . matches newline
uUnicode support
\nNewline
\tTab
\rCarriage return
\Escape special character
\. matches literal dot
\0Null character
^[\w.-]+@[\w.-]+\.\w{2,}$Email address
https?://[\w.-]+(:\d+)?(/\S*)?URL
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bIPv4 address
\d{4}-\d{2}-\d{2}Date (YYYY-MM-DD)
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}US phone number
#?([a-fA-F0-9]{3}|[a-fA-F0-9]{6})\bHex color code