Regex Tester
Understand Regex Tester
This tester runs a regular expression against sample text and shows every match, its position, and the contents of each capture group.
How it works
The pattern is compiled with the browser's own RegExp engine, so what happens here is exactly what happens in Node and in the browser — ECMAScript syntax, not PCRE or RE2. That engine backtracks: when a branch fails it rewinds and tries the next alternative, which is why a quantifier inside a quantifier, such as (a+)+$, can explore an exponential number of paths against a long non-matching string. That is catastrophic backtracking, and the two-second cutoff here exists to catch it.
When to use it
- Working out why a validation pattern rejects an input it should accept.
- Extracting fields from log lines before you commit to the parsing code.
- Checking capture-group numbering before wiring it into a replacement string.
- Testing a pattern against the awkward cases — empty string, non-ASCII text, multiple lines — rather than the happy path.
Watch out for
- The tester always runs with the global flag so you see every match. Your own code, with a non-global regex, gets only the first — and a global regex reused across calls carries lastIndex between them, which is why .test() can alternate between true and false on the same string.
- A pattern that takes seconds here takes seconds in production. If it ever runs against user-supplied input on a server that is a denial-of-service vector, and a user-supplied pattern is worse.
- JavaScript's \d, \w, and \b are ASCII-only. A pattern copied from Python or Java that relies on unicode-aware classes will silently miss non-English input.
- The dot does not match a newline unless you add the s flag, and ^ and $ anchor the whole string unless you add m.
Not the right tool for: Validating email addresses. Every regex for it is either wrong or unreadable — check for an @ with something on each side, then send a confirmation message.
Frequently Asked Questions
What regex flavour is used?
This tester uses JavaScript's built-in RegExp engine, which follows ECMAScript regex syntax. This is the same engine used in Node.js and browsers.
What are the supported flags?
JavaScript supports: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), and y (sticky). Enter them in the flags field.
How do I capture groups?
Use parentheses for capture groups: (\w+). Named groups use (?<name>\w+). Results show both indexed and named group values.
How to Use Regex Tester
- Paste or type your input in the input area above.
- The tool processes your input automatically or click Run.
- Copy or download the result using the action buttons.
- Use Ctrl+Enter to run quickly from the keyboard.