Developer Tools
Regex Tester
Test regular expressions live: see every match, capture groups and a highlighted preview.
Enter a pattern and test string, then press Test regex.
Highlighted matches
What is a regex tester?
Regular expressions are powerful but unforgiving — one misplaced character changes what matches. A regex tester lets you try a pattern against your own text and immediately see every match, where each match starts, what each capture group grabbed, and a highlighted view of the test string. It also catches invalid patterns with the browser's own error messages, so you learn what went wrong instead of guessing. Whether you are validating emails, parsing logs, or extracting data, testing first saves hours of debugging.
How to use this tool
- Type your pattern in the pattern field (without surrounding slashes).
- Tick the flags you need: g for all matches, i to ignore case, m for multiline ^ $, s for dot-all, u for Unicode.
- Paste the text to test into the test-string box.
- Press Test regex to see the match count, per-match details with capture groups, and the highlighted preview.
Key features
- Full flag support (g, i, m, s, u) via real RegExp construction — what you test is what JavaScript does.
- Every match listed with its character index and each capture group's value, including groups that did not participate.
- Highlighted preview: your test string is HTML-escaped first, then matches are wrapped in <mark> tags — safe and readable.
- Invalid patterns produce the exact SyntaxError message instead of failing silently.
- Zero-length match protection prevents infinite loops on patterns like a* or lookaheads.
Common use cases
- Validation patterns: testing email, phone, CNIC, or postal-code regexes before putting them in a form.
- Log parsing: extracting timestamps, IPs, or error codes from server logs.
- Data cleaning: previewing what a find-and-replace pattern will catch in messy text.
- Learning regex: seeing immediately how greedy vs lazy quantifiers behave.
- Code review: verifying a colleague's pattern actually matches the intended cases.
Practical tips
- Start with the g flag off to check the first match, then turn it on to see all of them.
- Use non-capturing groups (?:...) when you need grouping without capturing — it keeps group numbers clean.
- Anchor with ^ and $ (plus the m flag for multiline text) when validating whole inputs, or "abc" will match inside "xxabcxx".
- Prefer specific character classes (\d, [A-Za-z]) over . — dot matches more than you expect, including newlines with the s flag.
- Catastrophic backtracking (nested quantifiers like (a+)+$) can hang the tab; keep patterns simple or add atomic-style guards.
Frequently Asked Questions
Why does my pattern match nothing?
Usual suspects: case mismatch (try the i flag), the pattern being stricter than the text (e.g. \d+ when there are spaces), or anchors ^ $ without the m flag on multiline text. The highlighted preview makes misses obvious.
What do the flags g, i, m, s, u do?
g finds all matches instead of stopping at the first; i ignores case; m makes ^ and $ work per line; s lets . match newlines; u enables full Unicode handling for astral characters and \p{...} classes.
How do I read the capture group results?
Each match lists Group 1, Group 2, and so on in the order their opening parentheses appear in the pattern. A group that did not participate in a particular match is marked as such.
Why is my valid-looking pattern reported as invalid?
The tool uses the browser's native RegExp engine, so the error message is exact — often an unescaped special character, an unfinished group, or a bad flag combination. Fix what the message names.
Is my test data sent anywhere?
No. Pattern compilation and matching run entirely in your browser, so private logs or data samples never leave your device.