Regex Tester – Test and Debug Regular Expressions
Uses your browser's JavaScript regular expression engine, so syntax follows JavaScript, not PCRE or Python. Matching runs in a background worker and is stopped after 1.5 seconds, so a pattern with catastrophic backtracking cannot freeze the page.
What is a regex tester?
A regular expression (regex) is a short pattern for finding text: dates, emails, order numbers, anything with a predictable shape. A regex tester lets you try a pattern on sample text and see exactly what it matches before you put it in code. This one highlights every match, lists the capture groups, and previews a find-and-replace.
How to use it
- Type your pattern without the surrounding slashes, and pick the flags you need.
- Paste some test text. Matches are highlighted as you type.
- Check the table for each match's position and capture groups. Fill in the replacement box to preview a replace, using $1, $2 or $
for groups.
Example
Pattern and text:
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: Invoice dated 2026-10-17, due 2026-11-16.
It finds two dates. With the replacement $
Invoice dated 17/10/2026, due 16/11/2026.
Common building blocks
\d a digit \w a letter, digit or _ \s whitespace
. any character ^ start of text/line $ end of text/line
+ one or more * zero or more ? optional
{3} exactly three [abc] one of a, b, c (a|b) a or b
(?:...) group without capturing (?<name>...) named group
Frequently asked questions
What do the flags mean?
g finds every match instead of the first. i ignores upper and lower case. m makes ^ and $ match at each line. s lets the dot match line breaks. u turns on full Unicode matching.
Why does my pattern match nothing?
Check for an unescaped special character (such as . or ?), a missing flag, or text that differs by a space or case. Turn on the i flag first, since case is the most common cause.
Will it behave the same in Python, PHP or Java?
Mostly, but not always. This tester uses the JavaScript engine. Features such as lookbehind, named group syntax and flags differ between languages, so test in your own language before shipping.
What is catastrophic backtracking?
Some patterns, such as nested quantifiers like (a+)+, can take exponentially longer as the text grows. Here the match runs in a background worker and stops after 1.5 seconds so the page stays usable.
Is my text uploaded?
No. Everything runs in your browser.
Related tools
JSON Formatter · SQL Formatter · URL Encoder/Decoder · Text Compare
Results are estimates for information only and are not financial, tax or legal advice.