Regex Tester
Test, debug, and learn regular expressions — all in your browser, nothing sent to any server
Enter a regular expression and test string above.
What Is a Regular Expression?
A regular expression (regex) is a pattern language used to match, search, and manipulate text. Regular expressions are supported across virtually every programming language — JavaScript, Python, Java, Go, C#, Ruby, and more — and are essential for tasks like form validation, log parsing, data extraction, and search-and-replace operations. A regex pattern describes a set of strings that match a particular structure, from simple literal text to complex patterns with quantifiers, character classes, and groups.
How to Use This Regex Tester
- Enter your pattern in the Regular Expression field. The tool validates it in real time.
- Set flags using the checkboxes below the pattern:
- g (Global) — find all matches instead of stopping at the first
- i (Ignore Case) — match uppercase and lowercase letters interchangeably
- m (Multiline) — make
^and$match the start and end of each line, not just the entire string - s (Dot All) — make
.match newline characters as well - u (Unicode) — enable full Unicode matching and make
\p{...}property escapes work
- Paste your test string in the text area below.
- View results — matched portions are highlighted inline with color-coded spans, and the Match Details panel shows each match with its position and capture groups.
Switch to Replace mode to test regex-based replacements with live preview.
Understanding Capture Groups
Parentheses () in a regex create capture groups that extract specific portions of a match. For example, the pattern (\d{4})-(\d{2})-(\d{2}) applied to 2026-02-24 captures three groups: 2026, 02, and 24.
Named capture groups use the syntax (?<name>...). For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) gives each group a descriptive name that appears in the Match Details panel.
In Replace mode, reference capture groups with $1, $2, etc. For named groups, use $<name>. For example, replacing with $<month>/$<day>/$<year> transforms 2026-02-24 into 02/24/2026.
Common Regular Expression Patterns
| Pattern | Description | Example Match |
|---|---|---|
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | Email address | user@example.com |
https?://[^\s]+ | URL | https://example.com/path |
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b | IP address (v4) | 192.168.1.1 |
\d{4}-\d{2}-\d{2} | Date (YYYY-MM-DD) | 2026-02-24 |
#[0-9a-fA-F]{3,6}\b | Hex color code | #ff5733 |
\b\d{3}[-.]?\d{3}[-.]?\d{4}\b | US phone number | 555-867-5309 |
Use the Common Patterns buttons above the test string to quickly load these patterns. Note that email and URL validation is nuanced — no single regex covers all valid addresses per the RFC specifications.
ReDoS: Regex Security Considerations
Catastrophic backtracking occurs when a regex engine explores an exponential number of paths through the input. Patterns with nested quantifiers like (a+)+ or (a|a)* are the most common culprits. On adversarial input, these patterns can freeze a browser tab or crash a server process — a vulnerability known as ReDoS (Regular Expression Denial of Service). This tool detects common dangerous patterns and refuses to execute them on large input to keep your browser safe.
Frequently Asked Questions
What regex flags does this tester support?
This tool supports the standard JavaScript regex flags: g (global — find all matches), i (case-insensitive matching), m (multiline — ^ and $ match line boundaries), s (dotAll — . matches newlines), and u (Unicode mode — enables full Unicode matching and \p{} property escapes).
How do I use capture groups in replace?
In the replacement string, use $1, $2, etc. to reference numbered capture groups, and $<name> for named capture groups defined with (?<name>...). Use $& to insert the entire match.
Why is my regex not matching?
Common reasons include: forgetting the global (g) flag so only the first match is highlighted, using ^ and $ anchors without the multiline (m) flag on multi-line input, forgetting to escape special regex characters like ., (, ), [, ], or {, and having overly restrictive character classes.
What is the difference between greedy and lazy matching?
Greedy quantifiers (+, *, {n,m}) match as much text as possible, while lazy quantifiers (+?, *?, {n,m}?) match as little as possible. For example, given <b>bold</b>, the greedy pattern <.*> matches the entire string, while the lazy pattern <.*?> matches just <b>.
Is my data sent to a server? No. All regex matching, replacing, and validation happens entirely in your browser using JavaScript. No data is transmitted to any server. Your text stays completely private on your device.