How to use it
- Type the pattern without the slashes. The example finds dates written as 2026-11-10.
- Tick the flags you need. g finds every match, i ignores upper and lower case, and m and s change how line breaks are read.
- Paste your test text. The matches are highlighted at once, and the list under the text gives the position and groups of each one.
- Type a text in Replace with to see the result, then press Copy to take it.
How the matching works here
The page uses the regular expression engine built into your browser, the one JavaScript uses. Matches are found in order, from the start of the text. The position shown is the count of characters before the match, starting at 0, counted in UTF-16 units as JavaScript counts text.
The search runs in a background worker of your browser, so the page stays responsive. A search stops after 10,000 matches, and a text longer than 200,000 characters is not searched. A pattern that can match nothing, such as x*, moves on by one character after each empty match, so the search always ends. A search that takes longer than 2 seconds is stopped; see the section on catastrophic backtracking.
- Without the g flag, only the first match is shown, as String.match() does.
- The u flag reads an emoji or any other character outside the basic plane as one character.
- The d flag adds the start and end of each group to the list.
Catastrophic backtracking and the 2-second limit
A regular expression engine tries the ways a pattern could match, one after another. With some patterns, mostly a repeated group inside another repeated group such as (a+)+, the number of ways grows very fast: each extra character can double the work. This happens most when the text almost matches and fails only at the very end.
For example, the pattern (a+)+$ on a text of many letters a followed by an exclamation mark cannot match, because $ needs the end of the text. The engine still tries every way of splitting the letters before it gives up. With about 26 letters the search can already take a second or more on a typical computer, and each letter more makes it much slower. The time depends on your device.
This page runs each search in a background worker and stops it after 2 seconds, showing a message. The rest of the page keeps working, so you can change the pattern or the text and try again.
- Do not put a repeat inside another repeat over the same characters: write (a+)$ instead of (a+)+$. On the same text the safe pattern finishes at once.
- Be specific: use [a-z] or \d+ inside a group instead of a dot, so that the parts of a match cannot overlap in many ways.
- Test the pattern on a short sample of the text first, then on the full text.
- Anchor the pattern where you can: ^ at the start and $ at the end stop the engine from trying every starting point.
Replacement patterns
The replacement text follows the rules of String.replace() in JavaScript. A dollar sign starts a code that is replaced by the matched text:
| You write | It is replaced by |
|---|---|
| $1, $2 and so on | The text of the numbered group |
| $& | The whole match |
| $` | The text before the match |
| $' | The text after the match |
| $$ | A single dollar sign |
| A dollar sign, a less-than sign, the group name and a greater-than sign | The text of the named group |
Differences from PCRE and .NET
A pattern written for PCRE (PHP, many Linux tools) or for .NET (C#, Visual Basic) usually works here, but some features exist only in one of the engines. The table lists the ones that matter most.
| Feature | JavaScript (this page) | PCRE and .NET |
|---|---|---|
| Atomic groups and possessive quantifiers | Not available | Atomic groups in PCRE and .NET; possessive quantifiers such as a++ in PCRE |
| The anchors \A, \Z and \z | Not available: use ^ and $ | Available |
| A named group written as (?P<…>) | Not available | Available in PCRE |
| An inline option such as (?i) inside the pattern | Not available: set the flag instead | Available in .NET |
| Keeping text out of the match with \K | Not available | Available in PCRE |
| Replacing a named group | Dollar sign, less-than sign, name, greater-than sign | .NET uses dollar sign, brace, name, brace |
Worked example: three dates in one text
The sample pattern has three named groups: four digits for the year, two for the month and two for the day, separated by dashes. The text holds three dates, and they match at positions 14, 34 and 50, counted from 0 at the first letter.
With the replacement day, month, year written as the three group names (a dollar sign and each name between a less-than and a greater-than sign), the three dates are rewritten as 10.11.2026, 03.12.2026 and 15.01.2027. The result reads: Invoice dated 10.11.2026, paid on 03.12.2026. Due 15.01.2027.
Frequently asked questions
Which regular expression flavour does this tester use?
It uses the JavaScript engine built into your browser. Most patterns for searching, validating and cleaning text work the same in JavaScript, PCRE and .NET, but a few features differ, as the section on differences lists.
Why does the list stop at 10,000 matches?
Matches are collected in order. A very long list would be slow to draw and too long to read, so when a pattern matches more often, the first 10,000 matches are shown and the page says that the search stopped.
Why is my text refused when it is longer than 200,000 characters?
A very long text makes the page slow, and a pattern can take a long time on it. Test the pattern on a part of the text first, then on the rest, or cut the text into smaller pieces.
Why does the highlight skip some matches?
A match of no characters, such as the empty place that x* finds between letters, has nothing to highlight. It stays in the list with its position, so you can still see where it is.
Does the tester send my text to a server?
No. The matching runs in your browser, and the page does not store what you type or send it anywhere. Closing the page clears it.
What does the message about an invalid pattern mean?
The pattern cannot be read as a JavaScript regular expression. The message comes from the engine in English and names the problem, for example a bracket that is never closed.
Can I test a pattern written for PCRE or .NET here?
Often yes, when it uses only common features. If it has an atomic group, a possessive quantifier, \A or \z, or an inline option, rewrite that part for JavaScript first; the table shows which features those are.
Why does the page say that the pattern took too long?
The search did not finish within 2 seconds on this text, so the page stopped it. This usually means a pattern with a repeat inside another repeat, such as (a+)+, on a text that almost matches. The section on catastrophic backtracking shows a safer form.
Sources
- MDN: Regular expressions in JavaScript, including flags and groups
- MDN: String.prototype.replace(), the replacement patterns
- PCRE2 pattern syntax (the PCRE documentation)
- Microsoft: .NET regular expression language quick reference
Figures and text last checked on Tuesday, November 10, 2026.