Regex Tester
Test a JavaScript regular expression against sample text with live highlighting, showing every match, its character position, and any named capture groups.
FreeOnline Tool
Loading…
How to Use
- Enter your pattern in the "Regex" box without the surrounding slashes, for example \\d+.
- Enter the flags in the "Flags" box. The default is g for a global match, and you can change it to gi, gm, and so on.
- Type or paste the text you want to match into the test text area.
- Matching runs as you type: matched fragments are highlighted below, along with the position of each match and any named capture groups.
- Click "Load sample data" to see an example that extracts numbers from text.
Features
- Accepts any valid JavaScript regular expression syntax and flag combination (g, i, m, s, u, y).
- Matches live: change the pattern, the flags, or the text and results recalculate with no button to press.
- Highlights every matched fragment inside the original text so the coverage is easy to see.
- Lists each match individually with the matched content, the character index, and the contents of any named capture groups.
- Reports a clear error message when the pattern is invalid instead of breaking the page.
Use Cases
Developing a pattern before you ship it
Check that a regex matches exactly what you expect before dropping it into production code, rather than discovering the bug after release.
Validating data-cleaning rules
When processing logs or reports, confirm that the pattern you use to pull out fields such as order numbers or amounts is accurate.
Debugging form validation
Work through email, phone number, and ID validation patterns and confirm the edge cases behave the way you intend.
Learning regex syntax
Watch the highlighting change in real time to build intuition for how groups, quantifiers, and flags affect what gets matched.
FAQ
Why do I get different results with and without the g flag?
Without g the pattern returns only the first match. With g it keeps going and returns every matching fragment in the text, so the number and content of matches can differ.
What happens if my pattern has a syntax error?
The tool catches the error thrown by the JavaScript regex engine and shows the message in the results area. The page will not freeze or crash.
What are named capture groups and where do I see them?
A named group is written as (?<name>...). When a match succeeds, the captured name-value pairs are displayed as JSON underneath that match's details.
Is my pattern or test text sent anywhere?
No. All matching runs locally in your browser and nothing is uploaded, so it is safe to test against text that contains sensitive information.