Free Online Regex Tester
Build and debug JavaScript regular expressions with live match highlighting.
/ab+c/gi into the pattern box.
Match details
| # | Match | Index | Groups |
|---|---|---|---|
| No matches yet. | |||
Replace
Use $1, $2 or $<name> to insert captured groups.
How it works
- Type a regular expression, or paste one like /ab+c/gi.
- Toggle flags such as g (global) and i (ignore case).
- Enter test text — matches are highlighted as you type.
- Inspect capture groups in the table and try a replacement with $1, $2 or $<name>.
Frequently asked questions
Which regex flavour does this tester use?
It uses your browser's JavaScript (ECMAScript) regular expression engine — the same one used by JavaScript, TypeScript and Node.js. Most syntax is shared with other languages, but features like lookbehind and named groups can differ.
What do the flags g, i, m, s and u mean?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at every line, s lets . match newlines, and u enables full Unicode matching (needed for emoji and \p{…} classes).
Why was my pattern stopped for taking too long?
Patterns with nested quantifiers like (a+)+ can take exponential time on some inputs ("catastrophic backtracking"). The tester runs your regex in a background worker and stops it after 1.5 seconds so your browser never freezes.
How do I use capture groups in a replacement?
Wrap part of the pattern in parentheses, then use $1, $2… in the replacement. Named groups (?<name>…) can be inserted with $<name>, and $& inserts the whole match.
Test regular expressions as you type
Regular expressions are powerful but easy to get subtly wrong. This regex tester highlights every match in your sample text as you edit the pattern, lists each match with its position and capture groups, and previews a find-and-replace.
Quick regex reference
-
\ddigit,\wword character,\swhitespace,.any character -
*zero or more,+one or more,?optional,{2,4}between 2 and 4 -
^start and$end of input (or of each line with themflag) -
[abc]any of a, b or c;[^abc]anything except them -
(…)capture group,(?:…)non-capturing group,(?<name>…)named group -
(?=…)lookahead,(?<=…)lookbehind
Safe testing
Poorly written patterns can take seconds or even minutes on certain input — a problem known as catastrophic backtracking, which has caused real website outages. Your pattern runs in a background worker with a time limit, so the page always stays responsive and you learn about the risk before it reaches production.