Matches
Result
This regex tester runs JavaScript regular expressions against your text as you type, highlights every match and lists its position, capture groups and named groups. A replace tab previews $1 and $<name> substitutions live. It uses your browser’s own ECMAScript engine, the same one as Node.js and Chrome, and stops runaway patterns after one second.
How to use
- Type a pattern between the slashes, or paste a full /pattern/flags literal. Tap a common pattern such as Email or IPv4 to start from a tested one.
- Toggle flags: g finds all matches, i ignores case, m makes ^ and $ work per line, s lets the dot match new lines.
- Type or paste test text. Matches are highlighted as you type and listed below with their position and capture groups.
- Switch to Replace and enter a replacement using $1, $<name> or $& to see the result live. Tap any match, group or result to copy it.
- This is the JavaScript (ECMAScript) regex engine of your browser, the same one used by Node.js, Chrome and Deno. Lookbehind, named groups and \p{…} Unicode classes are supported.
- Matching runs in a background worker and stops after 1 second, so a pattern with catastrophic backtracking shows an error instead of freezing the page.
- In the replacement, \n and \t insert a new line or a tab. $$ inserts a literal dollar sign.
- Turn on the d flag to see the start and end index of each group.
- Share links include the pattern and flags, never your test text.
Flags that change the result
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at every line break, s lets the dot match new lines, u enables full Unicode and \p{…} property classes, y matches only at lastIndex, and d returns start and end indices for each group. Forgetting g is the most common reason a pattern seems to find only one result.
Reading a pattern
\d matches a digit, \w a letter, digit or underscore, \s whitespace and \b a word boundary. Quantifiers repeat the item before them: * is 0 or more, + is 1 or more, ? is 0 or 1 and {2,4} is 2 to 4 times. Add ? after a quantifier to make it lazy, so <.+?> stops at the first >. Parentheses capture a group; (?<year>\d{4}) names it and (?:…) groups without capturing.
Lookaheads (?=…) and (?!…) and lookbehinds (?<=…) and (?<!…) check what comes next or before without consuming it. For example \d+(?= USD) finds 120 in 120 USD but not in 120 EUR.
Avoiding slow patterns
Nested quantifiers such as (a+)+ or (.*)* can backtrack exponentially on text that almost matches, which can freeze a server: this is the ReDoS problem. Here matching runs in a background worker with a one-second limit, so you see an error instead of a hang. Prefer specific classes like [^,]* over .* and anchor patterns with ^ and $ when you validate a whole value.
Frequently asked questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), the engine built into your browser. It matches Node.js, Deno and TypeScript. Most syntax is shared with PCRE, Python and Java, but some features such as possessive quantifiers or atomic groups differ.
Why does my regex only find one match?
The g (global) flag is off. Without g, JavaScript stops after the first match. Turn on g to highlight and list every match.
How do I use capture groups in a replacement?
Write $1, $2 and so on for numbered groups, $<name> for named groups and $& for the whole match. $$ inserts a literal dollar sign.
How do I match a literal dot or bracket?
Escape it with a backslash: \. matches a period, \( a parenthesis and \[ a square bracket. Inside a character class most symbols are literal, so [.] also matches a dot.
Can a regex validate email addresses perfectly?
No. The full rules in RFC 5321 and 5322 are too loose and complex for a practical pattern. Use a simple regex to catch typos, then confirm the address by sending an email.
Is my test text sent anywhere?
No. Matching runs in your browser. Share links contain only the pattern and flags, never the text you tested.