โ Back to All Tools
๐ Regex & Debugging
Test, replace, and master regular expressions
๐งช Regex Tester
Regular Expression
Flags:
Test String
Quick Reference โ Common Patterns
.Any character (except newline)\dDigit [0-9]\DNon-digit\wWord char [a-zA-Z0-9_]\WNon-word char\sWhitespace\SNon-whitespace[abc]Character set[^abc]Negated set[a-z]Range^Start of string/line$End of string/line\bWord boundary*0 or more+1 or more?0 or 1 (optional){n}Exactly n times{n,m}Between n and m times(abc)Capture group(?:abc)Non-capturing groupa|bAlternation (or)(?=abc)Lookahead(?!abc)Negative lookahead(?<=abc)LookbehindUsage Guide
What it does
Tests a regular expression pattern against a string and highlights all matches. Shows match count, capture groups, and match indices.
How to use
- Enter your regex pattern (without delimiters)
- Select flags:
g(global),i(case-insensitive),m(multiline),s(dotAll) - Paste or type the test string
- Click Test Regex to see highlighted matches and group details
Sample Input
Pattern: (\w+)@(\w+)\.(\w+) Flags: g, i Text: Contact us at info@example.com or support@test.org
Sample Output
2 matches found Match 1: "info@example.com" (index 17-33) Group 1: "info" Group 2: "example" Group 3: "com" Match 2: "support@test.org" (index 37-53) Group 1: "support" Group 2: "test" Group 3: "org"
Real-World Use Cases
- Validating email addresses, phone numbers, URLs
- Extracting data from log files or structured text
- Building search-and-replace patterns for code refactoring
- Testing patterns before using in
grep,sed, or programming languages
๐ Regex Replace
Regular Expression
Flags:
Replacement String
Source Text
Result will appear here…
Usage Guide
What it does
Performs regex-based search and replace on text. Supports capture group references ($1, $2, etc.) in the replacement string.
How to use
- Enter the regex pattern to search for
- Enter the replacement string (use
$1,$2for captured groups,$&for full match) - Paste the source text
- Click Replace
Sample Input
Pattern: (\d{4})-(\d{2})-(\d{2})
Replacement: $2/$3/$1
Text: Event date: 2024-12-25
Sample Output
Event date: 12/25/2024
Replacement Tokens
$1, $2, $3...โ Captured group by number$&โ Entire matched string$`โ Text before the match$'โ Text after the match$$โ Literal dollar sign
Real-World Use Cases
- Reformatting dates, phone numbers, or IDs
- Renaming variables in code (e.g., camelCase โ snake_case)
- Cleaning up log files or CSV data
- Batch text transformations
๐ก๏ธ Regex Escape / Unescape
Result will appear here…
Usage Guide
What it does
Escape: Adds backslashes before all regex special characters so the string is treated as a literal match.
Unescape: Removes unnecessary backslashes from a regex pattern to reveal the plain text.
Characters Escaped
. * + ? ^ $ { } [ ] ( ) | \ /
How to use
- Select Escape or Unescape mode
- Enter your string
- Click Convert
Sample Input (Escape)
Price is $9.99 (USD)
Sample Output
Price is \$9\.99 \(USD\)
Sample Input (Unescape)
Price is \$9\.99 \(USD\)
Sample Output
Price is $9.99 (USD)
Real-World Use Cases
- Building dynamic regex patterns from user input
- Escaping file paths or URLs for regex matching
- Making literal strings safe for
RegExp()constructor - Debugging why a regex isn’t matching โ unescape to see what it actually searches
๐ Regex Cheatsheet
Character Classes
| Pattern | Description | Example |
|---|---|---|
| . | Any character except newline | a.c โ abc, a1c |
| \d | Digit [0-9] | \d+ โ 123, 42 |
| \D | Non-digit [^0-9] | \D+ โ abc, !@# |
| \w | Word character [a-zA-Z0-9_] | \w+ โ hello_42 |
| \W | Non-word character | \W+ โ @#!, … |
| \s | Whitespace (space, tab, newline) | a\sb โ a b |
| \S | Non-whitespace | \S+ โ hello |
| [abc] | Character set โ matches a, b, or c | [aeiou] โ vowels |
| [^abc] | Negated set โ anything except a, b, c | [^0-9] โ non-digits |
| [a-z] | Range โ lowercase letters | [a-zA-Z] โ letters |
Quantifiers
| Pattern | Description | Example |
|---|---|---|
| * | 0 or more (greedy) | ab*c โ ac, abc, abbc |
| + | 1 or more (greedy) | ab+c โ abc, abbc |
| ? | 0 or 1 (optional) | colou?r โ color, colour |
| {n} | Exactly n times | \d{3} โ 123 |
| {n,} | n or more times | \d{2,} โ 12, 123, 1234 |
| {n,m} | Between n and m times | \d{2,4} โ 12, 123, 1234 |
| *? | 0 or more (lazy/non-greedy) | <.*?> โ first tag only |
| +? | 1 or more (lazy/non-greedy) | “.+?” โ first quoted |
| ?? | 0 or 1 (lazy) | colou??r โ prefers color |
Anchors
| Pattern | Description | Example |
|---|---|---|
| ^ | Start of string (or line with m flag) | ^Hello โ starts with Hello |
| $ | End of string (or line with m flag) | world$ โ ends with world |
| \b | Word boundary | \bword\b โ whole word |
| \B | Non-word boundary | \Bword โ mid-word only |
Groups & References
| Pattern | Description | Example |
|---|---|---|
| (abc) | Capturing group | (ha)+ โ haha |
| (?:abc) | Non-capturing group | (?:ha)+ โ haha |
| (?<name>abc) | Named capturing group | (?<year>\d{4}) |
| \1 | Backreference to group 1 | (\w+)\s\1 โ word word |
| \k<name> | Named backreference | \k<year> |
| a|b | Alternation (or) | cat|dog โ cat or dog |
Lookaheads & Lookbehinds
| Pattern | Description | Example |
|---|---|---|
| (?=abc) | Positive lookahead | \d(?=px) โ 3 in 3px |
| (?!abc) | Negative lookahead | \d(?!px) โ 3 not before px |
| (?<=abc) | Positive lookbehind | (?<=\$)\d+ โ 99 in $99 |
| (?<!abc) | Negative lookbehind | (?<!\$)\d+ โ not after $ |
Flags
| Flag | Description | Example |
|---|---|---|
| g | Global โ find all matches, not just first | /a/g โ all a’s |
| i | Case-insensitive matching | /hello/i โ Hello, HELLO |
| m | Multiline โ ^ and $ match line boundaries | /^line/m โ each line |
| s | DotAll โ . also matches newline | /a.b/s โ a\nb |
| u | Unicode โ full Unicode matching | /\u{1F600}/u โ ๐ |
| y | Sticky โ match at exact position | lastIndex anchored |
Usage Guide
What it does
An interactive, searchable reference of regex syntax organized by category. Filter by keyword to quickly find the pattern you need.
How to use
- Type in the search box to filter patterns (searches across pattern, description, and examples)
- Browse categories: Character Classes, Quantifiers, Anchors, Groups, Lookaheads, Flags
Pro Tips
- Use the Regex Tester tab to try out any pattern from this cheatsheet
- Combine patterns โ e.g.,
\b\d{3}-\d{4}\bmatches phone numbers like 555-1234 - Start simple and build up โ test each piece of your regex individually