Regex tester
Type a pattern and your text and see every match and group highlighted. Flags and a replacement preview are included. Nothing is uploaded.
Free · no signup Runs in your browser
How do I test a regular expression?
Type your pattern in the Pattern box, choose the flags and paste the text to test. Every match is highlighted, and the list shows where each one starts and what its groups captured. Tick Replace to preview a replacement, where $1 stands for the first group. The pattern runs in a separate worker that is stopped after 1.5 seconds, so a badly written pattern cannot freeze the page.
A safe place to try patterns
A regular expression is a compact way of describing text: three digits followed by a dash, a word at the start of a line, an email-like shape. They are powerful and easy to get slightly wrong, so seeing the matches highlighted as you type is the quickest way to learn and to debug them.
This tester uses your browser's own JavaScript regular expression engine, so the result is exactly what your JavaScript code will do (other languages differ in small ways, especially around lookbehinds and named groups). The flags change the behaviour: g finds every match instead of the first, i ignores case, m makes ^ and $ match at each line, s lets the dot match line breaks, and u turns on full Unicode handling.
Some patterns, such as (a+)+ applied to a long string of a's followed by a b, take exponentially longer as the text grows. This is called catastrophic backtracking, and on a normal page it would freeze the tab. Here the test runs in a worker that is terminated if it takes more than 1.5 seconds, and you are told why.
It runs in your browser. What you type is never sent anywhere, and there is no sign-up.
When to use it
- Building a pattern for a form, a search or a script
- Debugging a pattern that matches too much or too little
- Previewing a replacement with groups before you run it
- Learning how regular expressions work
Mistakes it helps you avoid
- Forgetting the g flag and wondering why only one match shows.
- Using . when the text has line breaks: add the s flag.
- Greedy patterns such as .* that match far more than you meant.
- Nested repeats like (a+)+ that can freeze a program.
How it works
Everything happens in your browser as you type.
pattern + flags = new RegExp(pattern, flags), run by your browser's JavaScript enginematches = each match with its position, its groups ($1, $2...) and any named groupsreplacement = text.replace(pattern, replacement); $1 is the first group and $& the whole matchsafety = the test runs in a worker that is stopped after 1.5 secondslimit = up to 1,000 matches are listed
The engine is the one built into your browser, so it follows the ECMAScript regular expression rules, including lookbehind and named groups in current browsers. Patterns for PCRE, Python or .NET may need small changes. Matching an empty string advances by one character to avoid an endless loop.
Example: pulling out phone numbers
You test (\d{3})-(\d{4}) against 'Call 555-0199 or 555-0123'.
- Pattern(\d{3})-(\d{4})
- Flagsg
- Matches2: 555-0199 (groups 555, 0199) and 555-0123
- Replace with $2-$1Call 0199-555 or 0123-555
Two matches highlighted with their groups
Remove the g flag to find only the first.
Terms on this page
- Regular expression
- A pattern that describes text to find.
- Catastrophic backtracking
- A pattern that takes exponentially longer on some text and can freeze a program.
Common questions
Which regex flavour is this?
JavaScript (ECMAScript), the one in your browser. Most basics are shared with other languages, but some features differ.
What does the g flag do?
It finds every match in the text instead of stopping at the first.
Why was my pattern stopped?
It took over 1.5 seconds, which usually means catastrophic backtracking. Simplify nested repeats such as (a+)+.
Is my data uploaded?
No. Everything is processed in your browser and never sent anywhere.
How do I use groups in a replacement?
Use $1, $2 for the numbered groups and $& for the whole match.
What to work out next
Where these numbers come from
- MDN Web Docs — Regular expressions The syntax, flags and groups of JavaScript regular expressions.
- MDN Web Docs — RegExp How the RegExp object matches text.
- MDN Web Docs — Web Workers API How the test runs in a separate thread that can be stopped.
- MDN Web Docs — Clipboard API How a page copies text to your clipboard when you press a button.
Last verified 2026-10-25 The method on this page is checked against the sources above at least once a year. Spotted something out of date? Tell us and we will fix it.
Related tools
Find and replace
Find text and replace every match, with case and whole-word options, optional regular expressions, a match count and a highlighted preview.
Open toolJSON formatter
Paste JSON to check it is valid, then pretty-print, minify or sort its keys, and copy the result.
Open toolText compare
Paste two versions of a text and see what was added and removed, by word or by line.
Open toolPassword strength checker
Check how strong a password is: length, character types, repeats and sequences, common-password match, an entropy estimate and rough time to guess. Runs only in your browser.
Open toolURL encoder
Percent-encode text for use in a web address, or decode a %20 style string back to readable text.
Open toolUUID generator
Generate random version 4 or time-ordered version 7 UUIDs, one or many, in the format you need.
Open tool🧰 Developer and web tools
Small developer and web jobs done in your browser. What you paste or choose is never sent anywhere.
See all 24 tools in this section