Regex Tester
Write a regular expression and test it against sample text in real time. Highlights all matches, shows capture groups. Pairs with the URL Encoder for routing patterns and the JSON Formatter for testing against structured data when building routing patterns, and displays match count. Supports all JavaScript regex flags: g, i, m, s, u.
Developer Tools
What This Tool Does
Tests regular expressions against sample text in your browser in real time, highlighting all matches, groups, and capturing groups as you type. Supports JavaScript, PCRE, and Python regex syntax.
Who This Is For
- Developers writing input validation patterns who need to test against real data before deployment
- Data engineers cleaning messy datasets with regex-based transformations
- Security engineers writing log analysis patterns to detect anomalies
- Anyone learning regular expressions who wants immediate visual feedback on pattern matches
Example: Input: The regex \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b with the i flag, tested against a paragraph of text → Output: All email addresses in the text highlighted, with each capture group labeled and the full match list shown below
How to Test a Regular Expression
- Enter your regular expression in the Regex field (without delimiters — just the pattern itself).
- Select the flags you need:
g(global — find all matches),i(case-insensitive),m(multiline),s(dot matches newline). - Paste your test string into the input area.
- Matches are highlighted in real time as you type.
The tool shows capture groups separately. Regex patterns are used in JSON Schema validation and cron expressions — both tools are one click away. The tool also shows capture groups to verify that your groups extract the right data.
Regular Expression Syntax Quick Reference
| Pattern | Meaning | Example Match |
|---|---|---|
. | Any character except newline | a.c → "abc", "a1c", "a c" |
\d | Digit (0–9) | \d{4} → "2026" |
\w | Word character (letter, digit, _) | \w+ → "hello_world" |
\s | Whitespace | \s+ → spaces, tabs, newlines |
^ | Start of string/line | ^Hello → matches if string starts with "Hello" |
$ | End of string/line | end$ → matches if string ends with "end" |
* | Zero or more | go* → "g", "go", "goo", "gooo" |
+ | One or more | go+ → "go", "goo" (not "g") |
? | Zero or one (optional) | colou?r → "color" or "colour" |
{n,m} | Between n and m times | \d{3,4} → 3 or 4 digits |
[abc] | Character class | [aeiou] → any vowel |
[^abc] | Negated class | [^0-9] → any non-digit |
(abc) | Capture group | (\d{4})-\d{2} captures year |
(?:abc) | Non-capturing group | Groups without capture overhead |
(?<name>) | Named capture group | (?<year>\d{4}) |
a|b | Alternation (or) | cat|dog → "cat" or "dog" |
Common Regex Patterns
- Email address:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - US phone number:
\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4} - IPv4 address:
\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b - ISO date (YYYY-MM-DD):
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) - URL:
https?://[^\s/$.?#].[^\s]* - Hex color:
#(?:[0-9A-Fa-f]{3}){1,2}\b - ZIP code:
\d{5}(?:-\d{4})? - Credit card:
\b(?:\d{4}[\s-]?){3}\d{4}\b
Text Processing Workflow
Regex testing is part of a data validation and transformation workflow:
- Validate JSON — use JSON Schema instead of regex for structured data validation
- Test URL encoding patterns — use our encoder to generate the percent-encoded strings to test against — regex is useful for validating encoded URLs
- Validate cron expressions use a specific syntax that our Cron Parser can explain in plain English — cron syntax is a common regex use case
- Compare text before and after regex substitutions
Related Tools
- Building a regex to parse CSV fields? Test the pattern here, then apply it in your JSON pipeline. → process CSV data with validated regex
- Running regex on structured data? Export the matches as JSON and convert to CSV for analysis. → export regex match results to CSV
- Writing a regex reference? Document patterns in Markdown and convert to HTML to publish. → document regex patterns in a guide
- Migrating .NET regex code? Use the VB.NET to C# Converter for syntax translation. → convert VB.NET regex code to C#
Related Guides
Regular Expressions: A Practical Reference for Developers
The most useful regex patterns for validating emails, URLs, dates, phone numbers, and more.
TutorialCommon Regex Mistakes and How to Fix Them
Greedy vs lazy, anchors, and why your regex matches too much or too little.
GuideJSON vs XML vs CSV: Which Data Format Should You Use?
Regex is often used to parse and validate data in these formats — know when to use each.
Frequently Asked Questions
g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match line boundaries, not just string boundaries), and s (dotall — . matches newlines). Combine them: gi finds all matches case-insensitively.* and + are greedy — they match as much as possible. Adding ? makes them lazy — they match as little as possible. Example: <.*> on <a>test</a> matches the entire string. <.*?> matches only <a>.\. matches a literal dot. Other characters that need escaping: \*, \+, \?, \(, \), \[, \{, \^, \$, \|, \\.(\d{4}). When a match is found, the text matched by each group is available separately. Named groups ((?<year>\d{4})) let you access captures by name instead of index.(?P<name>) for named groups, while JavaScript uses (?<name>). Also check string escaping — in code, backslashes must be doubled in regular string literals.(a+)+ on a non-matching string cause exponential backtracking — the engine tries an enormous number of combinations before failing. This can hang your application. Avoid nested quantifiers on overlapping patterns. Test with strings that do NOT match to check performance.