01 / Live
Highlights as you type
Matches are marked in the text in alternating colours. Press Enter in the pattern to step through them.
Free tool
Type a regular expression and some test text, and every match is highlighted as you type, with its position and each capture group, named groups included. Read the pattern explained in plain English, switch flags on and off, preview a replace with $1 and $<name>, and export the matches. It runs your browser's JavaScript regex engine in the background with a time limit, so a runaway pattern never freezes the page.
Need a custom tool, app or website? Contact us →Matches
Replace
What the pattern says
Cheat sheet
Click to put it into the pattern at the cursor.
Start from
Use it in code
Keys
Tested in your browser. Nothing is sent anywhere. Your pattern, flags and replacement are remembered on this device; the test text is not.
See what matches
01 / Live
Matches are marked in the text in alternating colours. Press Enter in the pattern to step through them.
02 / Explained
Each piece of the pattern is spelled out, groups are numbered, and risky nested repeats are flagged.
03 / Safe
Matching runs in the background with a 2 second limit, so a runaway pattern is stopped, not your tab.
Guide
A regex tester lets you write a regular expression, paste some sample text, and see straight away what the pattern matches. This one highlights every match, lists each one with its position and capture groups, explains the pattern in plain English, and shows what a replace would produce. It uses the JavaScript regex engine built into your browser, the same one your code uses in a web page or in Node.
| Write | Matches |
|---|---|
. | Any one character except a line break (add the s flag to include line breaks) |
\d \w \s | A digit, a word character (letter, digit or underscore), a space or other whitespace |
\D \W \S | The opposite of each of the above |
[abc] [^abc] | One of a, b or c; any one character that is not a, b or c |
[a-z] | One character in the range a to z |
* + ? | Zero or more, one or more, zero or one of the thing before |
{3} {2,5} {2,} | Exactly 3, between 2 and 5, or 2 or more of the thing before |
*? +? | The same repeats, but taking as little as possible (lazy) |
^ $ | Start and end of the text (or of each line, with the m flag) |
\b | A word boundary, the edge between a word character and anything else |
(abc) | A capture group, listed as group 1, group 2 and so on |
(?<year>\d{4}) | A named group, listed by its name |
(?:abc) | A group that is not captured, for applying a repeat or a choice |
a|b | a or b |
(?=x) (?!x) | Only if followed by x; only if not followed by x |
(?<=x) (?<!x) | Only if after x; only if not after x |
\1 \k<name> | The same text that group 1, or the named group, matched |
\p{L} | Any letter in any language (needs the u or v flag) |
\. \( \\ | A literal dot, bracket or backslash |
a match A.^ and $ match at each line, not only at the start and end of the text.. match line breaks too.\p{...} classes work, an emoji counts as one character, and unknown escapes are errors.[\p{L}--[a-z]]. You can turn on u or v, not both. The button only shows if your browser supports v.Say you want UK style dates like 17/10/2026 out of a block of text. Start small and watch the highlights after each step.
\d+. Every run of digits lights up, including 17, 10 and 2026 separately.\d{2}/\d{2}/\d{4}. Now only the full date matches.(?<d>\d{2})/(?<m>\d{2})/(?<y>\d{4}). The list shows d as 17, m as 10 and y as 2026.$<y>-$<m>-$<d> into Replace with. The preview turns 17/10/2026 into 2026-10-17.\b at both ends so it does not match inside a longer number like 123/45/67890.$1, $2: the text of that numbered group.$<name>: the text of a named group.$&: the whole match. [$&] wraps every match in square brackets.$` and $': the text before and after the match.$$: a literal dollar sign.With the g flag on, every match is replaced. With it off, only the first one is.
example.com also matches exampleXcom, because the dot means any character. Write example\.com."\\d" inside a string. In the pattern box, write just \d. The Use it in code box writes the string form for you.".*" on a line with two quoted words grabs everything from the first quote to the last. Add a question mark, ".*?", to stop at the nearest quote.Nested repeats such as (a+)+$ or (\w+\s?)*$ can make the engine try a huge number of ways to split the text when it almost matches. The time grows very fast with each extra character, and in your own code that can hang a page or a server. Here the matching runs in a background worker. If it takes more than 2 seconds, the tester stops it, says so, and the page stays usable. The explanation panel also marks nested repeats. To fix one, use a single repeat where you can, make the parts inside unable to match the same text, or anchor the pattern.
Most everyday syntax, like classes, groups, repeats and anchors, works the same in JavaScript, Python, PHP, Java and .NET. The differences are in the edges. JavaScript has no possessive quantifiers or atomic groups, Python writes named groups as (?P<name>...), and flags go after the closing slash rather than inside the pattern. If your pattern is for another language, test the final version there too.
Cleaning up text before you search it? The remove line breaks tool joins wrapped lines, and the case converter changes text to upper, lower or title case.
Questions
JavaScript's (ECMAScript), built into your browser. PCRE, Python and others are close but differ in places like named group syntax, possessive repeats and atomic groups.
g finds every match, i ignores case, m makes ^ and $ work per line, s lets . match new lines, u turns on full Unicode, v adds set operations on top of u, and y matches only where the last match ended.
Check escaping first: a backslash in the pattern box is just one backslash, unlike in many code strings. Then read What the pattern says, which spells out each piece.
Yes: (?<year>\d{4}). They are listed by name, and you can use $<year> in the replacement.
No. Everything runs in your browser. The test text is not even saved, unless you copy a link, which puts it in the link itself.
The pattern needed more than 2 seconds on this text, which almost always means nested repeats that backtrack. The tester stops the search so the page does not freeze. See the section on catastrophic backtracking above for how to fix it.
Put \b on both sides, like \bcat\b. It matches cat on its own but not inside catalog or concat.
A greedy repeat like .* takes as much text as it can, then gives some back if it has to. A lazy repeat like .*? takes as little as it can. Use lazy when you want to stop at the first closing quote or tag.
Use \n for a line break, or \r?\n to also cover Windows line endings. To let a dot match line breaks too, turn on the s flag.
Yes, in this browser only. Your pattern, flags and replacement come back when you reopen the page. The test text does not, so private text is not left behind.