Tool
Regex Tester
Test a regular expression against a subject and inspect matches and capture groups.
Try it
This tool runs entirely in your browser. Nothing you type or paste is sent anywhere.
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.
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
All digits
{
"pattern": "\\d+",
"flags": "g",
"subject": "a1b22c333"
}Capture groups
{
"pattern": "(\\w+)@(\\w+)\\.com",
"subject": "[email protected]"
}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.