Regex tester
Type a pattern and some text. Every match is highlighted as you type, with the groups it captured and a replace preview. JavaScript flavor, running in your browser: nothing you paste leaves your computer.
3 matches. Flags: g all matches, i ignore case, m multiline, s dot matches newline, u unicode.
Matches
| # | Match | At |
|---|---|---|
| 1 | 2026-03-14 | 0 |
| 2 | 2026-03-14 | 85 |
| 3 | 2026-03-14 | 152 |
Replace
10:22:05 INFO Order #48213 paid, total $1,249.50 by ana.ruiz@example.com 10:23:41 WARN Retry 2 for order #48214 (card declined) 10:25:00 ERROR Payment gateway timeout after 30000 ms Phone: (305) 555-0142, alt 305-555-0199 IPv4: 192.168.1.20, 10.0.0.255, 256.1.1.1
Regex cheat sheet
. | Any character except a newline |
\d \w \s | A digit, a word character, a whitespace character |
\D \W \S | Anything that is not one of those |
[abc] [a-z] [^0-9] | One character from the set, a range, or not in the set |
^ $ | Start and end of the text (or of a line with the m flag) |
\b | A word boundary |
* + ? | Zero or more, one or more, zero or one |
{3} {2,5} {2,} | Exactly 3, between 2 and 5, at least 2 |
*? +? ?? | The same, but lazy: as few as possible |
(abc) | A capturing group |
(?:abc) | A group that does not capture |
(?<year>\d{4}) | A named group |
a|b | a or b |
\1 \k<name> | What group 1 or the named group matched |
(?=x) (?!x) | Lookahead: followed by x, not followed by x |
(?<=x) (?<!x) | Lookbehind: preceded by x, not preceded by x |
\. \$ \( | A literal dot, dollar sign or bracket |
$1 $<name> $& | In a replacement: group 1, a named group, the whole match |
How to use this regex tester
Put the text you are working with in the box: a few log lines, a column pasted from a spreadsheet, a list of emails. Write the pattern above it and watch the highlights. Add the g flag to see every match rather than the first, and i if case should not matter. The match table shows what each group captured, which is the quickest way to check an extraction pattern. The replace box runs the same pattern through a replacement, with $1 for the first group and $<name> for a named group, so you can test a cleanup before running it on the real file.
Patterns that repeat a repeated group, such as (a+)+, are refused, because they can take forever on the wrong input. Rewrite them so each repetition has a fixed part, usually a separator.
Want the patterns to come to you faster?
A tester shows you whether a pattern works on the text in front of you. It cannot tell you whether it works on the line that arrives tomorrow. Regexdrill checks every pattern against hidden test strings, across 52 exercises from character classes to lookbehinds, and five of them are free without an account.
Try the exercisesQuestions
Which regex flavor does this tester use?
JavaScript, the engine built into your browser, so what works here works in Node.js and in the browser unchanged. For everything on this page it behaves the same as PCRE (PHP, grep -P) and Python's re module, apart from a few syntax details such as named groups, which are (?<name>...) in JavaScript.
Is my text sent anywhere?
No. The pattern runs in your own browser. Nothing you type is uploaded, logged or stored, so it is safe to test on real log lines, emails or customer data.
Why does my pattern only find the first match?
Without the g flag a regex stops at the first match. Add g to find every match in the text. The highlighter on this page always shows every match so you can see the difference in the match list.
What do the flags mean?
g finds all matches instead of the first. i ignores case. m makes ^ and $ match at the start and end of each line instead of the whole text. s lets the dot match newlines. u switches on full Unicode, so \p{L} and emoji work.
How do I get better at writing regex?
Write patterns against inputs you have not seen. Regexdrill has 52 exercises that check each pattern against hidden test strings, from character classes to lookbehinds, with five free without an account.