Regex Tester
Test a regular expression as you type, see every match and group, and get each part of the pattern explained in plain English.
Runs in your browser. Nothing is uploaded.
Updated
Highlighted
Invoice 1042 issued 2026-11-12, due 2026-12-01. Paid on 2026-11-30.
grep -oP '(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})' input.txtHow to use Regex Tester
- Type a pattern and tick the flags you need.
- Paste test text and watch the matches highlight.
- Read the explanation, or switch to Replace to try a replacement.
Regex Tester at a glance
Typical use: Check that a date pattern finds 2026-11-12 in a log, then reformat it to 12/11/2026.
Uses your browser’s JavaScript regex engine. A pattern that runs longer than one second is stopped. Your text never leaves your device.
When to use Regex Tester
Build and debug a regular expression before you put it in code, a spreadsheet formula, a search box or a find-and-replace. Every match is highlighted as you type, capture groups are listed by number and name, and the explanation spells out each part of the pattern in plain English.
The tester uses your browser’s own JavaScript engine, so results are exactly what String.match, replace and RegExp do in Chrome, Firefox, Safari and Node.js. Your text never leaves your device.
Regex Tester examples
- Reformat dates: pattern
(\d{4})-(\d{2})-(\d{2}), replacement$3/$2/$1turns 2026-11-12 into 12/11/2026. - Find every price:
\$\d+(?:\.\d{2})?with thegflag matches $5, $19.99 and $120 but not 19.9. - Pull values out of a log:
status=(?<code>\d{3})lists each status code under the group name code, ready to copy.
Cheat sheet
| Pattern | Matches |
|---|---|
| . | any character except a line break (any character with the s flag) |
| \d \w \s | a digit, a word character (letter, digit, _), whitespace |
| \D \W \S | anything except a digit, word character or whitespace |
| [abc] [^abc] [a-z] | one of a, b, c · anything but a, b, c · a to z |
| ^ $ | start and end of the text (of each line with the m flag) |
| \b | a word boundary |
| * + ? | zero or more · one or more · optional |
| {3} {2,5} {2,} | exactly 3 · 2 to 5 · 2 or more times |
| *? +? | as few as possible (lazy) |
| (…) (?<name>…) | capture group · named group |
| (?:…) | group without capturing |
| a|b | a or b |
| (?=…) (?!…) | followed by · not followed by |
| (?<=…) (?<!…) | preceded by · not preceded by |
| \1 \k<name> | the same text a group already matched |
| \p{L} | a letter in any language (needs the u flag) |
JavaScript regex compared with PCRE and Python
- Named groups are
(?<name>…)in JavaScript and PCRE. Python needs(?P<name>…), so add the P when you copy a pattern to Python. - Replacement groups are
$1and$<name>here,\1and\g<name>in Python, and\1in sed. - Flags are written after the pattern (
/abc/gi). Inline flags like(?i)at the start are not supported in JavaScript. Use the i flag, or(?i:…)around part of a pattern (only in recent browsers). - Lookbehind can be any length in JavaScript. PCRE and Python need a fixed length, so
(?<=\d+)works here but fails there. - Not in JavaScript: possessive quantifiers (
a++), atomic groups ((?>…)),\A,\Zand recursion. Use^and$without the m flag instead of\Aand\Z.
Prefer the terminal?
In a terminal, grep and perl use Perl-compatible regex, which is close to JavaScript’s:
grep -oP '(?<year>\d{4})-(?<month>\d{2})' input.txt
perl -pe 's/(\d{4})-(\d{2})-(\d{2})/$3\/$2\/$1/g' input.txtBoth work line by line, so a pattern cannot match across lines. macOS grep has no -P; install GNU grep (ggrep) or use perl.
References
Frequently asked questions
Which regex flavour does this tester use?
JavaScript (ECMAScript), run by your browser’s own engine. Results match what RegExp, match and replace do in browsers and Node.js. Most simple patterns behave the same in PCRE (PHP, grep -P) and Python; the guide above lists the differences.
Is my text uploaded anywhere?
No. Matching, replacing and the explanation all run in your browser. Nothing you type is sent to a server.
Why does my pattern only find the first match?
Without the g (global) flag a JavaScript regex stops after the first match. Tick g to find and replace every match.
What does “pattern took too long” mean?
Some patterns, such as (a+)+$, try an enormous number of combinations on text that almost matches. This is called catastrophic backtracking. The tester stops any pattern that runs longer than one second, so the page never freezes. Make the repeated part more specific, or avoid a repeat inside a repeat.
How do I match a dot, a bracket or another special character?
Put a backslash before it: \. matches a dot, \( a bracket and \$ a dollar sign. The special characters are . * + ? ^ $ { } ( ) [ ] | / and the backslash itself.
How many matches are shown?
Up to 1,000 matches are found and highlighted, and the table lists the first 200. The highlighted preview covers the first 100,000 characters of the text.