Regex Tester — Test Regular Expressions in Real Time
Test and debug regular expressions in real time. Highlights all matches, shows capture groups and match positions, includes a quick-reference cheat sheet, and has common pattern presets for email, phone, URL, IP address, and date formats.
Common patterns
Frequently Asked Questions
What is a regular expression (regex)?
A regular expression is a sequence of characters that defines a search pattern. You can use regex to find, validate, extract, or replace text — for example, validating that an email address has the right format, or extracting all phone numbers from a document.
How do I learn regex?
Start with the basics: literal characters match themselves, `.` matches any character, `\d` matches a digit, `*` means zero or more. Practice with a tool like this tester, then try regexr.com or regular-expressions.info for deeper tutorials.
What are the most common regex patterns?
Email: /^[\w.-]+@[\w.-]+\.\w{2,}$/ · Phone (US): /\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}/ · URL: /https?:\/\/[\w.-]+(?:\/[\w.-]*)*/ · Date (YYYY-MM-DD): /\d{4}-\d{2}-\d{2}/ · ZIP code: /\d{5}(-\d{4})?/
What are capture groups in regex?
Capture groups, written with parentheses `(pattern)`, let you extract specific parts of a match. For example, `/([\w.-]+)@([\w.-]+)/` applied to 'user@example.com' gives group 1 = 'user' and group 2 = 'example.com'. Non-capturing groups use `(?:pattern)` — they group without capturing.
When should I use regex vs string methods?
Use string methods (`includes`, `startsWith`, `split`, `replace`) for simple operations — they're faster and more readable. Switch to regex when you need pattern matching (find any email), multiple replacements with the `g` flag, or validation (ensure a string has exactly the right format).