Regex Tester

Type a pattern and some text. Every match lights up as you type, with its groups listed below. Switch to Replace, Extract or Split to get text back out.

How it works

The tester uses the regular expression engine built into your browser. Every browser and Node.js follow the same ECMAScript rules, so a pattern that works here works in your JavaScript code with the same flags.

Each run happens in a background worker with a one-second limit. Some patterns take exponential time on the wrong input, and a JavaScript regex cannot be interrupted once it starts. Stopping the worker is the only way to stop it, so a slow pattern is stopped and reported instead of freezing the page.

Your pattern and your text stay in this tab. Nothing is sent to a server.

How to use it

  1. 1 Type the pattern without the slashes, such as \d{4}-\d{2}-\d{2}.
  2. 2 Tick the flags you need. g finds every match; without it only the first match counts.
  3. 3 Paste the text to test into the Test text box. Matches are highlighted and listed with their position and groups.
  4. 4 Choose Replace, Extract or Split to turn the matches into new text, then copy the result.

Good to know

  • Name your groups with (?<name>...). The name shows in the match list and you can use it in a replacement as lt;name>.
  • In a replacement, amp; is the whole match and $ is a literal dollar sign.
  • Split keeps captured groups in the output. Use (?:...) for a group you do not want in the pieces.
  • If a pattern is stopped for running too long, look for a repeated group that contains its own repetition, such as (a+)+ or (\w+\s?)+.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Pulling dates out of a log file, and the pattern that freezes

Regular expressions are easiest to learn on a real job. Say you have a log with lines like "2024-03-15 09:12:44 ERROR payment failed for order 8812" and you want every date. A first try is \d{4}-\d{2}-\d{2}: four digits, a dash, two digits, a dash, two digits. With the g flag on, the tester highlights each date and lists where it starts. Without g, it finds only the first one, because that is what JavaScript does.

Now you want the year, month and day separately. Wrap each part in parentheses: (\d{4})-(\d{2})-(\d{2}). Each match now has three groups, shown as 1, 2 and 3 in the table. Better, give them names: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}). Switch to Extract and pick Group <year>, and you get a list of years, one per line, ready to paste into a spreadsheet. Switch to Replace and type lt;day>/lt;month>/lt;year>, and every date in the text is rewritten as 15/03/2024.

The pattern still matches things that are not dates, such as 9999-99-99, or the middle of a longer number like 12024-03-155. Add word boundaries to stop the second problem: \b(\d{4})-(\d{2})-(\d{2})\b. The first problem is better solved after matching. A regex that only accepts valid calendar dates is long and hard to read, and it still cannot know that 2023-02-29 does not exist. Match the shape with the regex, then check the value in code.

Some patterns look fine and then hang. Try (\w+\s?)+$ against a long line of words that ends with a full stop. The engine first matches the whole line, fails at the full stop, then backs up and tries every other way to divide the words between the inner \w+ and the outer +. The number of ways doubles with each character, so 30 characters can take minutes. In a web server this is a real attack, called ReDoS. Here the run is stopped after one second and you are told why. The fix is to make each character belong to the pattern one way only, for example ^(\w+\s)*\w+$ or simply ^[\w\s]+$.

This tester has limits. It only speaks JavaScript regex, so a pattern copied from Python or PHP may need changes: Python’s (?P<name>...) becomes (?<name>...), and possessive quantifiers such as a++ do not exist. The one-second limit applies to the whole run, so a fair pattern over a very large text can also hit it. The highlight shows the first 1,000 matches and the table the first 200, although counts and outputs use them all.

Frequently asked questions

Which regex flavour does this tester use?

JavaScript (ECMAScript). It supports lookahead, lookbehind, named groups, the s flag and Unicode property escapes such as \p{L} with the u flag. It does not support features found only in PCRE, Python or .NET, such as possessive quantifiers, atomic groups, recursion or \A and \Z.

Why was my pattern stopped?

It ran for more than one second on your text. That almost always means catastrophic backtracking: the engine tries every way to split the input between nested quantifiers before it gives up. (a+)+$ against 30 letter a characters followed by a b already takes billions of steps. Rewrite the inner part so it can match only one way.

Why do I only get one match?

The g flag is off. Without it, JavaScript stops at the first match, and Replace changes only the first one. Tick g to find them all.

Is there a limit on matches?

Every match is counted, up to one million. The first 1,000 are highlighted and the first 200 are listed in the table. Replace, Extract and Split always use every match.

Is my text uploaded anywhere?

No. The pattern runs in a worker inside this browser tab. You can test against log files or customer data without them leaving your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.