How to use
- Type your regex into the Regular expression pattern field, without the surrounding slashes.
- Paste the text you want to test into Test string.
- Under Flags, turn on ignore case if capitalization should not matter.
- Open Matches to inspect each match and its capture groups.
- Open Explain to read a token-by-token breakdown of your pattern.
Examples
Capture a year and month
2026-10-01
1 match: 2026-10 group y = 2026, group m = 10
Swap username and domain in email addresses
bob@example.com, amy@test.com
example:bob, test:amy
Extract usernames as a list
bob@example.com amy@example.com
bob amy
JavaScript regex cheatsheet
Characters
. | Any character except a line break (any character with s) |
\d | Digit 0–9 |
\D | Not a digit |
\w | Word character: letter, digit or _ |
\W | Not a word character |
\s | Whitespace (space, tab, line break…) |
\S | Not whitespace |
\t | Tab |
\n | Line feed |
\uFFFF | Unicode character by code |
\p{L} | Unicode letter (needs u flag) |
\. | Escaped special character: a literal dot |
Classes
[abc] | One of a, b or c |
[^abc] | Any character except a, b or c |
[a-z] | A character in the range a–z |
[a-zA-Z0-9_] | Same as \w |
Anchors
^ | Start of text (start of line with m) |
$ | End of text (end of line with m) |
\b | Word boundary |
\B | Not a word boundary |
Quantifiers
* | 0 or more |
+ | 1 or more |
? | 0 or 1 (optional) |
{3} | Exactly 3 |
{2,} | 2 or more |
{2,5} | Between 2 and 5 |
*? | Lazy: as few as possible |
Groups and lookaround
(abc) | Capturing group |
(?<name>abc) | Named capturing group |
(?:abc) | Non-capturing group |
\1 | Backreference to group 1 |
\k<name> | Backreference to a named group |
a|b | a or b |
(?=abc) | Followed by abc |
(?!abc) | Not followed by abc |
(?<=abc) | Preceded by abc |
(?<!abc) | Not preceded by abc |
Replacement
$& | The whole match |
$1 | Group 1 |
$<name> | Named group |
$` | Text before the match |
$' | Text after the match |
$$ | A literal $ |
Want to compare the text before and after a replacement? Paste both versions into the Diff Checker. For bulk clean-up without regex, try the Text Cleaner; to escape text for URLs use URL Encode/Decode.
FAQ
Does this regex tester support Python, PHP or .NET?
It uses your browser's JavaScript (ECMAScript) RegExp engine, not Python, PCRE or .NET. Some syntax differs between engines; the tester flags several common non-JavaScript constructs with hints.
Why does my regex find only the first match?
Without the g flag, the tester finds only the first match. Turn on global under Flags to find all matches.
Why did my regex time out?
Each run stops after one second. Nested repetition such as (a+)+ can cause catastrophic backtracking; simplify the pattern or test a smaller sample.
Is my test text uploaded or saved?
Matching runs in your browser, and the tool does not send your pattern or test text to a server. The test text is not saved between visits; the pattern, flags, replacement, list template and current tab are remembered in localStorage. Clear deletes that saved state.
Can I share a regex with its test text?
Share link copies a URL containing your pattern, test text and settings. The data is compressed, not encrypted, so anyone with the link can read it. Share link is disabled if the URL would exceed 8,000 characters.