Regex Tester
Test regular expressions live with highlighted matches, capture groups, match positions and flags — plus ready-made patterns for email, URL, IP.
About the Regex Tester
This regex tester evaluates your regular expression against any test string as you type, highlighting every match directly in the text so you can see exactly what the pattern grabs — and what it misses. A live counter shows the number of matches, and a details table lists each match with its position and captured groups.
All five common JavaScript flags are available as checkboxes: g (global), i (ignore case), m (multiline), s (dotall) and u (unicode). Invalid patterns don't break anything — you get the parser's error message in plain sight so you can fix an unbalanced bracket or bad quantifier immediately.
A dropdown of common patterns (email, URL, IPv4 address, ISO date, phone number) fills the pattern box with a solid starting point that you can adapt, making it a practical reference as well as a testing sandbox.
How to Use the Regex Tester
- 1Type a regular expression, or insert a common pattern from the dropdown.
- 2Tick the flags you need — g finds all matches, i ignores case.
- 3Paste your test string and watch matches highlight live.
- 4Inspect positions and capture groups in the match table.
Frequently Asked Questions
How do I test a regular expression online?
Type your pattern in the expression field and your sample text in the test string box — matching happens live with no button to press. Matches are highlighted in the text, counted, and broken down in a table showing each match's index and capture groups. If the pattern has a syntax error, a friendly message explains what's wrong.
What do the regex flags g, i, m, s and u mean?
g (global) finds every match instead of stopping at the first; i makes matching case-insensitive; m makes ^ and $ match at each line boundary rather than only the string's start and end; s lets the dot . also match newline characters; and u enables full Unicode mode, required for \p{…} property escapes and correct handling of characters outside the basic plane.
Why does my regex match everything or return empty matches?
Patterns where everything is optional — like a*, (\d+)? or .* — can match the empty string at every position, producing a huge count of zero-length matches. Anchor the pattern (^…$), make at least one part required (+ instead of *), or be more specific. The tester displays empty matches as ∅ so they're easy to spot.
What are capture groups and how do I read them in the results?
Parentheses in a pattern create capture groups that extract sub-parts of each match: in (\d{4})-(\d{2})-(\d{2}) matching 2024-01-15, group $1 is 2024, $2 is 01 and $3 is 15. The match table lists every group's value per match — undefined means that optional group didn't participate.
Are the built-in email and URL patterns 100% accurate?
They are practical, widely-used patterns that catch the overwhelming majority of real-world cases — but no reasonable regex fully implements the email or URL RFCs, which allow exotic forms. Use them as strong starting points for validation and extraction, and pair email validation with a confirmation message for the cases that matter.