
Online Regex Tester: A Practical Guide to Debugging Regular Expressions
Test a JavaScript regex, inspect capture groups, and preview a $1 replace in the browser before the pattern lands in production code.
A pattern that looks right still deserves a failing input
A regular expression is a tiny program. It is easy to write, easy to paste from a comment thread, and expensive when it accepts the wrong string or hangs the tab. The online regex tester runs the browser's JavaScript RegExp engine on a pattern and a test string that you paste locally. Matches are highlighted in the test string, match cards list the groups, and an optional replace preview is available. There is no flavor switch: the engine is not PCRE, not Python and not the one inside a database. It belongs to the same family as Node and as a JSON Schema pattern evaluated by Ajv. Ajv 8 compiles that pattern with the u flag by default, so switch u on to get the same result. The page sits on the developer utilities hub, next to slugify and the case converter, which cover the jobs that should not be a hand-rolled expression at all.
Where the tester helps, and where a unit test should take over
A pattern you are about to paste into code, a fixture, or a JSON Schema pattern keyword.
Some jobs already have a tool that encodes the rules. A handwritten expression will drift.
Patterns that survive a glance and fail on real input
The tester compiles the field with new RegExp. Recursive constructs such as (?R) are invalid here and surface the engine's error. The slashes you see around the field are interface decoration, not part of the pattern. Pasting /(\w+)/gi unwraps the pattern and merges those flags with the ones already toggled; it does not replace them. If g was already on, it stays on. A second trap is the backslash: the field is the regex source, so \d means digits. Pasting \\d from a JSON or Java string looks for a literal backslash followed by d.
On "one" and "two", the pattern ".+" with g returns one match: the whole span from the first quote to the last. The engine takes as much as it can, then gives characters back until the final quote fits. Switching to ".+?" changes the result, but not because it understands which words you meant. With g it returns two matches, "one" and "two". Lazy means the shortest success, not a semantic filter. "[^"]*" is the pattern that cannot cross a quote.
A shape such as (a+)+ against a long run of a's that never reaches the expected ending can explode into catastrophic backtracking. The tester has no server timeout. It runs on the main thread of the tab, which means the page can freeze. The tool does cap what it returns: global search stops and shows a truncation warning, either because it hit the soft cap of 500 matches or because a zero-width pattern tripped the loop guard (the engine advances one character after an empty match so that g cannot spin forever). That guard does not make a nested quantifier safe. The upload accepts .txt, .md and .log files up to 32 MiB into the test string, still locally. A full log combined with a nested pattern can lock the tab.
The Email-ish chip is [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,} on a@b.co x not-an-email y@z.io. With g it highlights a@b.co and y@z.io. It is a demo, not a full RFC 5322 validator, and the tool documentation says so. Sticky mode is just as limited: flag y matches only at the start of the test string here, because lastIndex is reset on every run. It will not “continue where the last match stopped” across runs. Results also do not update while you type. Changing the pattern, the flags, the mode or the text clears the cards until you press Test again.
What each flag and mode actually changes here
Six flags, no others. Default is g alone.
Match mode lists the matches. Replace mode also shows the substituted string, using JavaScript replacement patterns.
A named capture is the same group as its number. The card shows it once.
Run one case, then change a single variable
On the regex tester, nothing runs while you type. The previous cards clear as soon as the inputs change.
Write the source, not a literal
Type \d+, not /\d+/g. If you do paste a /pattern/flags literal, paste or blur unwraps it and merges flags. Empty pattern is an error. Invalid pattern shows the JavaScript message.
Toggle only the flag you mean to test
g is on by default. Turn it off to confirm you really wanted a single match. Add m before trusting ^ on a second line. Add u before \p{…}: without it, \p{L} matches the literal characters p{L}, not letters. Leave y off unless you are checking a match that must start at index 0.
Press Test, then read the card as well as the highlight
The highlight shows where the match sits. The card shows the index and each group. Select a card to emphasize that match. In Replace mode, read the replaced text above the cards before copying the pattern into code.
The chips are fixtures, not a library of production validators.
(\w+)=(\d+) on user=42 role=admin env=prod\d, \w, \s, ., [], ^, $, \b, +, *, ?, and () at the caret. Brackets and parentheses place the caret inside.txt, .md, or .log file up to 32 MiB into the test string, in the browser. Prefer a short excerpt when the pattern is not obviously linearThe same engine in Node
Node's RegExp is the same language. matchAll requires the g flag. Without g, use exec once.
Basic example
Replacement patterns are the ones the replace field accepts. This is the built-in chip, not a custom template language.
Basic example
No install, nothing uploaded, flags and groups visible, replace preview included. The limits: no flavor switch, sticky mode only at index 0, at most 500 returned matches, and a nested quantifier can freeze the tab because execution is local. Keep the page for a fixture and a code review. Commit the pattern beside tests when it guards production input. If the expression was only standing in for a slug or a case change, switch to slugify or the case converter instead of maintaining it.
Conclusion
Test the pattern against a string that should fail, in the engine that will run it. For JavaScript that engine is RegExp, which is what the regex tester uses. That includes a JSON Schema pattern that you will later compile with Ajv in the JSON Schema validator, with u switched on because Ajv 8 does the same. Do not treat the email-ish chip as a validator, do not expect flag y to resume mid-string, and do not feed a nested quantifier a 32 MiB log. When the job is a slug or a case change, leave the expression alone and use the dedicated tool on the developer utilities hub.
Test a pattern in the browser
Related Articles

Paste a token and a JWKS to check an RS256, ES256 or HS256 signature in your browser. How kid picks the key, measured errors and the claims to check.

HTTP/2 and HTTP/3 change how files travel, not how big they are. Measured sizes, compile times and bundling tests show what minification still saves.

Convert a Unix epoch to a readable date and back, tell seconds from milliseconds, and avoid time zone, JWT and clock change traps, all in your browser.