How to use the Regex Tester
- Type your pattern between the slashes. No need to type the slashes yourself. Its parts show in color as you type: each capturing group has its own color, used again in the explanation, the match list and the test texts.
- Turn flags on or off in the flags menu at the end of the pattern (press
g): each flag says what it does.g(find all matches) is on by default, and your choice is remembered. - Paste a test text into Test 1. Matches are highlighted as you type, and listed on the right with their capture groups and positions. Click a match or a group to select it in the test.
- Read the Explanation on the right: every part of the pattern in plain English, with groups and options nested.
Click a part (like
\d{4}) to select it in the pattern box. Collapse the explanation or the matches with their title when you need the room. - Press Add test for more texts (up to 20). Every test shows its own matches; the list on the right shows the test you last clicked or typed in. Click a match there to select it in that test.
- Optional: set Expect on a test to Should match or Shouldn't match. The test then shows Pass or Fail, and a summary above the tests says how many pass ("2 of 3 pass") and which ones fail.
- Collapse a test with its title to keep the list short, and drag the handle under a test (or click it) to make it taller or shorter. × removes a test (with Undo).
- Press Save (Ctrl + S) to keep the pattern, its flags and your tests. Saved patterns appear right under the pattern box: one click loads them again. Manage lets you rename or delete them. While you work on a save, Save asks whether to update it or save a new copy, and New (in the bar at the top, next to Save) begins an empty one (it asks first if you have unsaved changes).
Example
Pattern (?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>\d{2}) with the g flag. The explanation reads it part by
part. It starts with
(?<year>…)Group year (number 1)\d{4}A digit (0–9), exactly 4 times
and shows the month group's two options one level deeper: 0[1-9] Either: the character “0”, then one character
from “1” to “9”; 1[0-2] Or: the character “1”, then one character from “0” to “2”.
In the first test,
- 2026-11-18: Regex Tester ships
- Not a date: 2026-1-5
it finds one match, Match 1 · 3–12 · 2026-11-18 (characters 3 to 12), with the groups year · 3–6 · 2026,
month · 8–9 · 11 and day · 11–12 · 18. 2026-1-5 doesn't match because the month needs two digits.
Press Example to see tests at work. The month part 0[1-9]|1[0-2] accepts only 01 to 12, so Test 3,
Not a real date either: 2026-13-45, finds no match and passes Shouldn't match. With a plain \d{2} for the
month, 2026-13-45 would match and Test 3 would fail: that's the kind of mistake tests catch.
Flags
| Flag | Name | What it does |
|---|---|---|
g | Global | Find all matches, not just the first |
i | Ignore case | a also matches A |
m | Multiline | ^ and $ match at the start and end of each line |
s | Dot all | . also matches line breaks |
u | Unicode | Treat emoji and other symbols as single characters; enables \p{…} |
y | Sticky | Only match exactly where the last match ended |
Cheat sheet
| Pattern | Matches |
|---|---|
. | Any character except a line break |
\d \w \s | A digit, a word character (letter, digit, _), a space or tab |
\D \W \S | The opposite of the above |
[abc] [^abc] [a-z] | One of a, b, c · anything but a, b, c · a lowercase letter |
^ $ \b | Start · end · word boundary |
* + ? | 0 or more · 1 or more · 0 or 1 |
{3} {2,5} | Exactly 3 · between 2 and 5 |
*? +? | As few as possible (lazy) |
(…) (?<name>…) (?:…) | Capture group · named group · group without capturing |
a|b | a or b |
(?=…) (?!…) | Followed by · not followed by |
FAQ
How does the explanation work?
It reads your pattern with the same rules as JavaScript (including the u flag, which changes some of them) and
describes each part in plain words: groups, options, character classes, how often a part repeats, anchors and
backreferences. Letters next to each other are shown as one text, like “abc”. Invisible characters, like a zero-width
space, are named with their code (U+200B) so you can spot them. If the pattern isn't valid, fix the error shown under
the pattern box first.
Which regex flavor is this?
JavaScript (ECMAScript), the same engine your browser and Node.js use. Most patterns work the same in other
languages, but features like lookbehind, named groups and \p{…} differ in places.
Why did it say my pattern took too long?
Some patterns, like (a+)+$, can make the engine try billions of combinations (called “catastrophic backtracking”).
We stop after 1 second so the page never freezes, and skip the tests after it instead of waiting a second for each.
Try making the repeated part more specific. Safari sometimes gives up on such patterns silently and reports no match,
so we warn you when a pattern was slow and mark that test as "may be incomplete".
When does a test pass or fail?
Should match passes when the pattern finds at least one match in the test, Shouldn't match passes when it finds none. Without an expectation a test just shows its matches. If the pattern isn't valid, was stopped, or may be incomplete (see the question above), the test shows Not checked instead of a result you can't trust.
Where are saved patterns kept?
Only in this browser on this device. A save keeps the pattern, its flags and the tests you had (their text and expectation), and only when you press Save: your test texts are never kept otherwise. Saves don't sync to other devices, and clearing your browser data deletes them.
Is my text uploaded?
No. Matching happens in your browser. See the privacy page.