Regex Tester
Test a regular expression against a subject and inspect matches and capture groups.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Found 3 match(es) for /\d+/g.
How it works
- Compiled a fresh regular expression from the pattern and flags.
- Advanced through the subject collecting every global match.
- Recorded each match's start index, length, value, and capture groups.
- A fresh RegExp is compiled on every call, so lastIndex never leaks between tests.
Methodology
- Compile a fresh ECMAScript RegExp from the pattern and flags, then run it against the subject.
- Advance through the subject collecting every global match, or test once for a single match.
- Record each match's start index, length, value, and capture groups without exposing a stack trace as a result.
Usage
- Enter a regular expression pattern.
- Optionally add flags such as g, i, or m.
- Paste the subject text and read the matches and groups.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
All digits
{
"pattern": "\\d+",
"flags": "g",
"subject": "a1b22c333"
}Capture groups
{
"pattern": "(\\w+)@(\\w+)\\.com",
"subject": "ada@example.com"
}Limitations
Global state and lastIndex
A RegExp with the g or y flag stores its position in lastIndex. Reusing one object between tests is a classic source of 'every other match is skipped' bugs. This tool compiles a new RegExp for each call, so results are reproducible.
Frequently asked questions
- Which flags are supported?
- The JavaScript flags g, i, m, s, u, and y, each at most once.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.