Regex Tester
Test a JavaScript regular expression against your text as you type, see every match highlighted with its position and groups, and preview a replacement. It runs on your device and stops patterns that run too long.
The pattern only, without the slashes or flags. Switch flags on in the bar above.
0 characters · 200,000 remaining
Optional. Use $1 for a group, $<name> for a named group, or $& for the whole match.
The matches appear here as you type.
Type a pattern and some text to see the matches. Nothing leaves this device.
On this device · background worker
No signup. Your input is never uploaded.
How to use the Regex Tester
Type your pattern into Pattern, without the slashes.
Switch the flags you need on or off in the bar above.
Paste the text you want to search into Text to test, and read the highlighted matches and the match list.
Optionally type a replacement to preview the changed text, then copy the matches or the result.
An example
Finding email addresses
You enter
Pattern: (?<user>[\w.]+)@(?<domain>[\w-]+\.[a-z]{2,}) with the g flag, on: Write to ada@example.com or grace.hopper@navy.milYou get
2 matches: ada@example.com at position 9, and grace.hopper@navy.mil at position 28. Replacing with $<user> at $<domain> gives: Write to ada at example.com or grace.hopper at navy.mil
How the Regex Tester works
Your pattern is compiled with your browser's own JavaScript regular expression engine and run over the text in a background worker. Every match is listed with its position and groups, and the worker is stopped if a pattern runs longer than two seconds.
Limits to know about
- Patterns up to 2,000 characters and text up to 200,000 characters are accepted.
- Only the first 1,000 matches are listed.
- It uses JavaScript regex rules. Other languages may treat some patterns differently.
- A pattern that takes more than 2 seconds is stopped.
See also: JavaScript regex cheat sheet: classes, groups, lookarounds, flags, and traps
Questions about the Regex Tester
It uses the JavaScript regular expression engine built into your browser, so patterns behave the way they do in JavaScript, Node.js, and TypeScript. Some features differ in other languages such as Python, PHP, or Java.
Switch on Global to find every match, and leave it off to find only the first. The other flags make the pattern ignore case, match at the start and end of every line, let a dot match line breaks, and treat text as Unicode.
Some patterns with nested repeats can take an enormous time to fail on certain text. The tool runs each test in a separate worker and stops it after two seconds, then tells you, so the page never freezes.
Type the new text in Replace with. Use $1 for the first group, $<name> for a named group, and $& for the whole match. The result is shown below the matches and can be copied.
Last updated