About Regex Tester
Regex Tester helps you write, debug and understand regular expressions. Every match is highlighted as you type, capture groups are listed one by one, and you can preview replacements before using the pattern in your code.
How it works
Your pattern is compiled with the browser's native JavaScript regex engine, so what you see here is exactly what runs in Node.js, Deno and every modern browser. Modern features are supported, including named groups ((?<year>\d{4})), lookbehind ((?<=\$)\d+) and Unicode property escapes such as \p{L} with the u flag.
Matching runs in a background worker with a time limit. A pattern with catastrophic backtracking, like (a+)+$ on a long string, can't freeze the page. You'll get a timeout warning instead, which is also a useful hint that the pattern could hang in production.
Quick reference
\ddigit,\wword character,\swhitespace,.any character*zero or more,+one or more,?optional,{2,5}between 2 and 5^start and$end of the text (or of each line with themflag)( )capture group,(?: )non-capturing group,a|beither a or b[abc]one of these characters,[^abc]none of these
Tips for better patterns
- Start from the pattern library (emails, URLs, dates, phone numbers) and adapt it rather than writing from scratch.
- Add the
gflag to see every match, not just the first. - Use anchors (
^…$) when validating a whole input, so "abc123xyz" doesn't pass as a number. - Prefer specific classes like
[^"]*over.*. They're faster and less likely to over-match. - Name your groups.
$<year>is far easier to read than$3six months later.
Worked example
You need to pull ISO dates out of a log file. Paste a few lines, type (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) and turn on the g flag. Every date is highlighted and the named groups are listed, so you can export the pattern as JavaScript code.
Limits to know about
- It uses the JavaScript regex engine. Patterns written for PCRE, Python or other flavors can behave differently or fail.
- Matching runs in a worker with a time limit, so a pattern with catastrophic backtracking shows a timeout warning instead of freezing the page.
- The tester shows what a pattern matches. It cannot tell you whether the pattern is the right one for your data.
Troubleshooting
- The pattern matches nothing: Check the flags (for example i for case-insensitive) and escape special characters such as . and ( with a backslash.
- It matches too much: Use anchors with ^ and $, and prefer specific classes like [^"]* instead of .*.