Regular expression builder and tester
Build a regular expression from pieces you can name, see every match and group as you type, read it explained in plain words, replace, split and test it. JavaScript flavour; it runs on your device.
How it works
Type a pattern at the top and a text below it: every match is marked in the text as you type, alternating between two looks so that neighbours can be told apart, with the parts captured by groups underlined. A match of nothing, such as ^ on an empty line, is a thin caret.
- The pattern is coloured by part: groups, sets, repetitions, places and escapes. A problem is named in words with its column, and marked: a bracket that is not closed, a repetition with nothing to repeat, an escape that Unicode mode refuses, a group name that does not exist. Only what your browser refuses is called a problem.
- Flags are the toggles beside the pattern; each says what it does when you point at it or reach it with Tab. u and v cannot be on together.
- Matches lists every match with its place and its groups, by number and by name. Choose one to select it in the text.
- Explanation says what each part of the pattern does, in order, as an indented list. Choose a part to see it in the pattern; put the cursor in the pattern to find its part.
- Replace, Split and Tests show the text with a replacement made, the text cut by the pattern, and lines that must match or must not, each passing or failing.
- Code gives the pattern as JavaScript: a literal, the same built from a string, and a few lines that use it.
Building a pattern
Open Builder for a palette of pieces: characters, places, repetitions, groups and look-arounds, and common patterns such as an email address, a date or a UUID. A piece goes in at the cursor; a repetition or a group goes round the part you have selected, so choosing Digit and then One or more gives \d+.
A short cheat sheet
| Write | It matches |
|---|---|
. |
any character but a line break |
\d \w \s |
a digit, a word character, white space (capitals for the opposite) |
[abc] [^abc] [a-z] |
one of a, b or c; anything but those; a to z |
^ $ \b |
the start, the end, a word boundary |
a? a* a+ |
a once or not; any number of times; at least once |
a{3} a{2,5} a{2,} |
three times; two to five; two or more |
a+? |
as few as possible |
(…) (?<name>…) (?:…) |
a group, a named group, a group not captured |
a|b |
a or b |
(?=…) (?!…) (?<=…) (?<!…) |
followed by, not followed by, preceded by, not preceded by |
\1 \k<name> |
the same text as group 1, or as the group named |
$1 $<name> $& $$ |
in a replacement: a group, a named group, the match, a dollar sign |
Questions and answers
Which kind of regular expression does it use?
JavaScript's, as defined by ECMAScript 2025 and as your browser runs it, with named groups, look-behind, Unicode properties (\p{…} with u or v), match indices (d), and v's sets. Other languages (PCRE, Python, Java, .NET) share most of it, but not all; possessive quantifiers, atomic groups and inline flags such as (?i) at the start are not JavaScript.
Is the text I test sent anywhere?
No. The pattern is read, explained and run in your browser, on your device. Nothing you type or open is uploaded. The page remembers your last pattern and text on this device, and a copied link holds them in the address.
Why did it stop with a message about time?
Some patterns try an enormous number of ways on a text that almost matches, such as (a+)+$ on a long line of a followed by b. The pattern runs apart from the page, and after one second it is stopped, so the page never freezes. The message names the part that is the likely cause; repeat it only once, or make it more precise.
How are the places of matches counted?
From 0, in the characters JavaScript counts (UTF-16 code units). A match at 0–4 starts at the first character and ends before the fifth. An emoji counts as two, as it does for JavaScript's own index.
What is the difference between u and v?
Both read the pattern as Unicode characters and allow \p{…}. v adds nested sets, intersection (&&) and subtraction (--) in sets, strings in \q{…} and properties of strings such as \p{RGI_Emoji}, and asks for a few more characters to be escaped in sets. They cannot be used together.
Valid · 3 groups · JavaScript (ECMAScript 2025), as your browser reads it
Group Text Place 1 year20269–13 2 month1114–16 3 day2617–19 Group Text Place 1 year202629–33 2 month1234–36 3 day0137–39 Group Text Place 1 year1999109–113 2 month01114–116 3 day09117–119
Each part of the pattern, in order. Choose one to see it in the pattern; the cursor in the pattern finds its part here.
Flags: g global
$1 for group 1 · $<name> for a named group · $& for the whole match · $$ for a dollar sign
The text cut wherever the pattern matches. What a group captures is kept between the pieces, as split does.
13 pieces
- Piece 1
Released - Group
2026 - Group
11 - Group
26 - Piece 2
, updated - Group
2026 - Group
12 - Group
01 - Piece 3
. Not dates: 2026-13-45, 26/11/2026, 20261126. Order #4182 shipped on - Group
1999 - Group
01 - Group
09 - Piece 4
at 14:30.
One test to a line. Each line is tried on its own.
4 of 4 pass
2026-11-26Passes: it matches1999-01-09Passes: it matches2026-13-45Passes: it does not match26/11/2026Passes: it does not match
As a literal
/\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b/gBuilt from a string
new RegExp('\\b(?<year>\\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\\d|3[01])\\b', 'g')Using it
const pattern = /\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b/g;
const text = 'Released 2026-11-26, updated 2026-12-01.\nNot dates: 2026-13-45, 26/11/2026, 20261126.\nOrder #4182 shipped on 1999-01-09 at 14:30.';
for (const match of text.matchAll(pattern)) {
console.log(match.index, match[0], match.groups);
}
const replaced = text.replace(pattern, '$<day>/$<month>/$<year>');
const pieces = text.split(pattern);