Regex Tester
Test and debug regular expressions with real-time match highlighting and capture group display.
//
Common Patterns
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | |
| Indian Mobile | (\+91|0)?[6-9]\d{9} |
| URL | https?:\/\/[^\s]+ |
| Date DD/MM/YYYY | (0[1-9]|[12]\d|3[01])\/(0[1-9]|1[012])\/\d{4} |
Regex: The Most Powerful Text Processing Tool for Developers
Regular expressions (regex) are patterns used to match, search, extract and validate text. They are used in every programming language — validating email addresses, parsing log files, extracting data from HTML, checking phone number formats, finding and replacing patterns in code. Despite their power, regex patterns are notoriously hard to write and test. Our Regex Tester provides real-time match highlighting with capture group display and includes common ready-to-use patterns.
Frequently Asked Questions
How to write a regex for email validation? ▼
Basic email regex: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} This matches most standard emails. For stricter validation per RFC 5322, the pattern is more complex. Note: no regex perfectly validates all legal email addresses — always combine regex with a confirmation email flow.
What is the regex for Indian mobile number validation? ▼
Pattern: (\+91|0)?[6-9]\d{9} — This matches: optional +91 or 0 prefix, followed by a digit from 6–9 (valid Indian mobile starts), followed by exactly 9 more digits. Flags: use g for global, test with the string "9876543210" or "+919876543210".
How to match a URL with regex? ▼
Simple URL pattern: https?:\/\/[^\s]+ — matches http:// or https:// followed by any non-whitespace characters. For strict URL validation, use a dedicated URL parser (URL() constructor in JavaScript) rather than regex, as URLs have complex edge cases.
What do regex flags mean? ▼
Common flags: g (global — find all matches, not just first), i (case-insensitive — A matches a), m (multiline — ^ and $ match line start/end), s (dotAll — . matches newline too), u (Unicode mode). Example: /pattern/gi matches all occurrences case-insensitively.
How to test if a string matches a regex in JavaScript? ▼
Three methods: (1) regex.test(str) — returns true/false, (2) str.match(regex) — returns array of matches or null, (3) str.matchAll(regex) — returns iterator of all matches with capture groups (requires g flag). Our tester uses matchAll() for complete match details.
What is a capture group in regex? ▼
Capture groups are parts of a regex in parentheses ( ) that extract specific portions of a match. Example: (\d{4})-(\d{2})-(\d{2}) matches a date and captures year, month and day as separate groups 1, 2 and 3. Named groups: (?\d{4}) lets you access match.groups.year.