DeveloperApr 3, 2026 ยท Updated Oct 13, 2026 ยท 3 min read

How to Test Regular Expressions Online

Test regular expressions against your own data. We ran five popular "common patterns" against known answers: the email pattern accepted user..dots@example.com, the date pattern accepted February 30, and the phone pattern rejected +1 numbers.

๐Ÿ”
Try the Regex Tester
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01Why Test Against Your Own Data02Five "Common Patterns", Tested03Capture Groups and Named Groups04Flags05Debugging a Pattern

Why Test Against Your Own Data

A pattern that matches the examples you had in mind can still accept garbage and reject valid input. An online tester shows every match as you type, so you can paste real samples, add the awkward cases and watch what changes. Our Regex Tester runs the pattern in a background worker with a 2-second limit, so a catastrophic pattern such as (a+)+$ stops with a message instead of freezing the tab, and it lists every match with g, including empty ones.

Five "Common Patterns", Tested

We ran the patterns most tutorials hand out (this guide included, until now) against inputs where the right answer is known, using JavaScript's RegExp (October 14, 2026; script in our test folder):

Pattern forWrongly acceptedWrongly rejected
Email ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$user..dots@example.com, .lead@example.com, a@-bad-.comjosรฉ@example.com (an internationalized address, RFC 6531)
US phone ^\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$(555 123-4567 (unbalanced bracket), 123-456-7890 (no US area code starts with 1)+1 555 123 4567
IPv4 ^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}โ€ฆ$01.02.03.004 (leading zeros, which some parsers read as octal)โ€”
Date ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$2026-02-30, 2026-04-31, 2025-02-29โ€”

The lesson is not that these patterns are useless: they are good filters for obvious typos. But a regex cannot know calendars or numbering plans. Validate dates by parsing them (a valid date round-trips), email by sending a confirmation message, and phone numbers with a library built on the official numbering data, such as Google's libphonenumber.

Capture Groups and Named Groups

Parentheses capture the text they match. (\d{4})-(\d{2})-(\d{2}) on 2026-04-15 gives groups 1-3 as 2026, 04 and 15. JavaScript also supports named groups, written (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}), which come back as match.groups.year and so on. (This guide used to print that example as live HTML, which hid the names; the angle brackets are now escaped.) Use (?:โ€ฆ) for grouping without capturing.

Flags

Debugging a Pattern

Start from the smallest pattern that matches one real example, then add one piece at a time and re-check your list of good and bad inputs. Watch for greedy quantifiers (.* runs to the last possible match; .*? stops at the first), anchors you forgot (without ^ and $ a pattern matches inside longer text), and nested quantifiers on overlapping input, which cause catastrophic backtracking. The Regex to English tool explains a pattern piece by piece.

Frequently Asked Questions

How do I test a regex pattern online?+
Paste the pattern into the Regex Tester, choose flags, and paste test text: every match and its capture groups are listed as you type, and an invalid pattern shows the browser's error message. For a plain-English explanation of each part of a pattern, use the Regex to English tool.
What is a capture group in regex?+
Parentheses () create a capture group that extracts a specific portion of the match. For example, (d{4})-(d{2}) applied to '2026-04' captures '2026' in group 1 and '04' in group 2.
What does the g flag do in regex?+
The g (global) flag finds all matches in the string, not just the first one. Without it, most regex functions stop after the first match.
Try it yourself

Use the Regex Tester โ€” free, no signup required.

โšก Open Regex Tester
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.
โšก Try the free Regex to Plain English โ†’