About this regex tester
A regular expression tester runs a JavaScript-flavor pattern against sample text entirely inside this browser tab, using the same RegExp engine your own JavaScript code runs on. Type a pattern and choose flags, add a test string, and see every match plus its capture groups without leaving the page.
Matches, capture groups and replacements are computed with the native RegExp implementation built into your browser, so behavior matches what new RegExp(pattern, flags) would produce in your own code. No pattern, flags or text is sent anywhere.
Regular expressions are powerful but easy to get wrong. A pattern might work for test cases but fail on real data, or perform catastrophically slow on certain inputs. This free online JavaScript regex tester runs patterns against test text using your browser's native RegExp engine—the exact same engine your own JavaScript code runs on. Write a pattern, choose flags, supply test text, and instantly see every match with its capture groups, all locally.
The inspector shows every match with its position and all capture groups: positional groups by number ($1, $2) and named groups by label ($<name>). The replace-all section previews what String.prototype.replace would produce, letting you refine replacement text before deploying it in your code. Supports all modern JavaScript flags: global (g), ignore case (i), multiline (m), and dot-matches-newline (s).
Use cases include email validation, data extraction from logs or HTML, password pattern enforcement, URL parsing, and text replacement in bulk operations. Test complex patterns before using them in production to avoid silent failures or performance problems. The tool warns about catastrophic backtracking risk—some patterns can freeze your browser when tested against certain inputs, so start with short test strings for unfamiliar patterns.
How to use this tool
-
01
Write a pattern and choose flags
Enter the body of the pattern without surrounding slashes, then check Global, Ignore case, Multiline or Dot matches newline as needed for the behavior you want.
-
02
Add a test string and run Test
Paste or type the text to match against, then choose Test, or press Ctrl/Cmd+Enter from the pattern or test-string field, to list every match with its index and capture groups.
-
03
Optionally replace every match
Enter replacement text using $1, $2 or $<name> for capture groups, then choose Replace all to preview the resulting string in the read-only output field.
Worked examples
Extract a user name and domain from an email address
Pattern: (?<user>[\w.+-]+)@(?<domain>[\w-]+\.[a-z]{2,}), flags: gi, text: "Contact ada@example.com for details."Match 1: "ada@example.com" at index 8 — Group "user": "ada", Group "domain": "example.com"Limits and edge cases
- This tool runs the browser's synchronous RegExp engine with no timeout of any kind. A pathological pattern with nested, overlapping quantifiers, such as (a+)+b tested against a long run of "a" characters, can trigger catastrophic backtracking and freeze or crash this browser tab; client-side JavaScript has no way to interrupt a runaway match once it starts, so try unfamiliar patterns against short strings first.
- Flags behave exactly as JavaScript defines them: g finds every non-overlapping match instead of only the first, i ignores case, m makes ^ and $ match line boundaries instead of only the start and end of the whole string, and s lets . match line terminators as well.
- Replace all always applies global matching internally, even with the Global checkbox unchecked, because a non-global replace can only ever change the first match. Reported match results, in contrast, respect the Global checkbox exactly as set.
- A capture group that does not participate in a given match, such as an optional group that did not match anything, is reported as not participating rather than as an empty string, since JavaScript itself distinguishes undefined from "".
Standards and references
Common questions
Does this tool send my pattern or test text anywhere?
No. Matching, capture groups and replacement all run locally in your browser's JavaScript engine. Nothing is uploaded to a server.
Why did my browser tab freeze while testing a pattern?
Some patterns cause catastrophic backtracking, where matching time grows exponentially with input length. That is a property of the pattern and the native RegExp engine, not a bug in this page; reload the tab, then simplify the pattern or shorten the test string.