About this tool
Regex Tester lets you try a regular expression against your own text and see the result straight away. Matches are highlighted as you type, every match is listed with where it sits and what each group captured, and a replace mode previews exactly what your text becomes with $1 or $<name> in the replacement.
It is built for developers writing validation or search-and-replace code, and for anyone learning regular expressions. Under the tester, each part of your pattern is explained in plain English, step by step, and a cheat sheet puts common tokens into the pattern with one click. Ready-made patterns for email addresses, web addresses, phone numbers, dates, postcodes, IP addresses and hex colours give you a working start.
Some patterns can take practically forever on the wrong text, which freezes most online testers. Here the matching runs in a separate background worker with a 2-second limit, so if a pattern runs away the tool stops it, tells you why, and the page stays responsive. It uses your browser’s own JavaScript engine, so results match your code, and nothing you type leaves your device.
How to use Regex Tester
- Type a pattern into the Pattern box, or choose one from “Ready-made patterns…”. There is no need for the slashes; they are shown for you.
- Turn flags on or off with the buttons under the pattern: g finds all matches, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u turns on Unicode mode and y makes the match sticky.
- Type or paste your text into “Test text”. Matches are highlighted on the right and listed under “Matches and groups”; click a row to outline that match.
- To replace, choose Replace, type the replacement (use $1, $<name> or $&), then press “Copy result”.
- Read “What this pattern means” for a step-by-step explanation, and press “Copy as /regex/” to paste the finished pattern into your code.
The ready-made date pattern \b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b finds 2026-01-01 and 2026-03-15 but not 2026-13-01. With the replacement $<day>/$<month>/$<year>, they become 01/01/2026 and 15/03/2026.
Features
- Live matching as you type, using the JavaScript regular expression engine in your browser.
- Highlights that don’t rely on colour alone: each match is underlined and outlined, neighbouring matches alternate styles, empty matches show as a thin marker, and hidden start and end labels are there for screen readers.
- Match table with the start and end position of each match and every capture group, numbered and named, including groups that didn’t take part.
- Replace mode with a live preview supporting $1, $<name>, $& and $$.
- A plain-English explanation of each token, indented by group, plus a warning when a repeat sits inside another repeat.
- Background matching with a 2-second time limit, so a runaway pattern is stopped instead of freezing the tab.
- Friendly error messages for unclosed brackets, nothing to repeat, backwards ranges, bad group names and more.
- A click-to-insert cheat sheet and 13 ready-made patterns with sample text.
Tips and good to know
- Without the g flag a regular expression stops at the first match, which is why only one match appears. Turn g on to find them all.
- To match a symbol that has a special meaning, such as . + * ? ( ) [ ] or $, put a backslash before it: \. matches a real full stop.
- If the tool stops a pattern after 2 seconds, look for a repeat inside a repeat, like (a+)+ or (\w*)*. Make the inner part more specific, or remove one of the repeats.
- This tester uses JavaScript rules. Most patterns work the same in Python, PHP or Java, but features such as look-behind and named groups can be written differently there.
- The ready-made email and phone patterns catch typical cases. They are deliberately practical rather than a full implementation of every rule in the standards.
Frequently asked questions
Is my text or pattern uploaded?
No. Matching, replacing and explaining all happen in your browser on your device. Logs or customer data you paste into the test box are never sent anywhere.
Is it free? Is there a size limit?
It is free with no sign-up. Large texts work fine; the tool counts up to 10,000 matches, highlights the first 5,000 and lists the first 300 in the table.
Does it work on a phone or offline?
Yes. The layout stacks on small screens and works in Safari on iPhone. After the page has loaded, testing needs no connection.
Which regex flavour does it use?
JavaScript (ECMAScript), exactly as your browser runs it. That makes it ideal for front-end code, Node.js and anything else that uses JavaScript regular expressions.
Why did it say my pattern took too long?
Some patterns, usually with a repeat inside a repeat, can try an enormous number of ways to match text that almost fits. This is called catastrophic backtracking. The tool runs each test in a background worker and stops it after 2 seconds so your tab doesn’t freeze.
How do I use a captured group in the replacement?
Write $1 for the first group, $2 for the second and so on. For a named group such as (?<year>…), write $<year>. $& inserts the whole match, and $$ gives a real dollar sign.
Page last reviewed
