Regex Tester
Test a regex against your text with matches highlighted - free, no signup.
What this tool does
Enter a pattern, flags and some test text, and every match is highlighted directly in the text as well as listed separately with its position and any capture groups. An invalid pattern - like an unclosed bracket - is reported clearly instead of the page silently breaking, and a pattern that could match an empty string (like a*) is handled safely instead of freezing the page in an infinite loop.
Tests a JavaScript-flavoured regular expression against text you provide, highlighting every match directly in context.
Lists each match separately with its character position, numbered capture groups, and named groups (like (?<year>\d{4})).
Reports a malformed pattern with the browser's own error message rather than failing silently.
How to use it
- Enter your regex pattern and flags (like g for global, i for case-insensitive).
- Paste your test text.
- Read the highlighted matches and the detailed list below them.
Why use this tester
Regular expressions are quick to write and easy to get subtly wrong. Seeing matches highlighted in context, with groups and positions, shows what a pattern really does.
Why we built it
We built the regex tester to highlight matches in the text itself and list positions and capture groups separately. Apply a pattern to a whole document with the find and replace tool and pull items out with the email extractor.
For a neighbouring job there is also the JavaScript Key Code Finder.
Who this tool is for
- Developers writing and debugging patterns
- Data analysts cleaning text
- Students learning regular expressions
When to use it
- Developing and debugging patterns.
- Extracting data from text.
- Learning regular expressions.
- Checking validation rules.
Why zero-length matches need special handling
A pattern like a* can match an empty string - and that can freeze a naive tester.
A pattern such as a* (zero or more of the letter 'a') can legitimately match an empty string at a position with no 'a' at all. A regex engine run in a loop that doesn't account for this can get stuck matching the same empty string at the same position forever, freezing the page. This tool explicitly advances past a zero-length match before searching again, so patterns like this are handled safely and still show every real match, rather than the page hanging or the tool being restricted from testing them at all.
Tips for the best result
A pattern that looks right can match too much or too little. Test with realistic text, including awkward cases, before you use the expression in code.
- Turn on the global flag to see every match, not just the first.
- Use the capture group list to check each part of the match is what you expect.
- Anchor patterns with ^ and $ when you need the whole string to match.
- Remember the flavour is JavaScript - lookbehind and named groups work in current browsers, but some PCRE features do not.
What you give it, and what you get back
| Item | Details |
|---|---|
| Input | A pattern, flags and test text. |
| Output | Highlighted matches, positions and capture groups. |
| Flavour | JavaScript (ECMAScript). |
Issues you may run into
| What you see | Why it happens | What to do |
|---|---|---|
| Pattern works elsewhere but not here | The regex flavour differs. | Adjust for JavaScript syntax. |
| Catastrophic slowness | A pattern with nested quantifiers. | Simplify the pattern. |
| Only one match | The g flag is missing. | Add the global flag. |
Assumptions and limitations
- Uses JavaScript's regex flavour (ECMAScript) - a pattern written for PCRE, Python or another regex dialect may behave slightly differently here if it uses flavour-specific syntax.
- Match results are capped at 5,000 to keep the page responsive against a pathological pattern/text combination.
Frequently asked questions
How do I test a regex online for free?
Enter your pattern, flags and test text, and every match highlights instantly with its position and capture groups listed below. No signup, no upload.
What flags are supported?
The standard JavaScript regex flags - g (global), i (case-insensitive), m (multiline), s (dotall), u (unicode) and y (sticky) - enter any combination.
What happens if my pattern is invalid?
The tool shows the browser's own error message (for example, an unclosed bracket or an invalid quantifier) instead of failing silently or crashing the page.
Does this show capture groups?
Yes - both numbered groups (from plain parentheses) and named groups (using the (?<name>...) syntax) are listed for every match.
Can a pattern freeze the page?
No - a pattern that can match a zero-length string (like a*) is handled by advancing the search position manually, and total matches are capped, so the page stays responsive even with tricky patterns.