Regex Tester
Test and debug regular expressions
Table of Contents
Test and debug regular expressions with live matching. Essential for writing and validating regex patterns.
Note: This tool uses JavaScript regex engine. See below for differences between regex flavors.
Test Regex
Common Use Cases
- Input Validation: Test email, phone, SSN patterns
- Log Parsing: Extract data from log files
- Data Extraction: Pull specific patterns from text
- Search & Replace: Test patterns before using in code
- URL Matching: Validate or extract URL components
- Password Requirements: Test password complexity rules
Common Patterns
Email:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Phone (US):
^\d{3}-\d{3}-\d{4}$IP Address:
^(\d{1,3}\.){3}\d{1,3}$URL:
^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\bDate (YYYY-MM-DD):
^\d{4}-\d{2}-\d{2}$Hexadecimal Color:
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Regex Flags
- g (global): Find all matches, not just the first
- i (ignore case): Case-insensitive matching
- m (multiline):
^and$match line starts/ends - s (dotall):
.matches newlines - u (unicode): Enable full Unicode support
- y (sticky): Match from lastIndex position
Special Characters
.- Any character except newline\d- Digit (0-9)\w- Word character (a-z, A-Z, 0-9, _)\s- Whitespace^- Start of string/line$- End of string/line*- 0 or more+- 1 or more?- 0 or 1{n}- Exactly n times{n,m}- Between n and m times
Regex Flavor Differences
Different programming languages use different regex engines with varying features. This tool uses JavaScript (ECMAScript) regex.
JavaScript (ECMAScript)
- Lookahead:
(?=...)and(?!...)✅ Supported - Lookbehind:
(?<=...)and(?<!...)✅ Supported (ES2018+) - Named Groups:
(?<name>...)✅ Supported (ES2018+) - Atomic Groups:
(?>...)❌ Not supported - Possessive Quantifiers:
*+,++❌ Not supported - Unicode:
\p{...}✅ Supported withuflag
Python (re module)
- Lookahead/Lookbehind: ✅ Full support
- Named Groups:
(?P<name>...)(different syntax) - Atomic Groups: ❌ Not supported
- Conditional:
(?(id)yes|no)✅ Supported - Verbose Mode:
(?x)for comments ✅ Supported
PCRE (PHP, grep -P, Perl)
- Most Features: ✅ Most comprehensive regex engine
- Atomic Groups:
(?>...)✅ Supported - Possessive Quantifiers: ✅ Supported
- Recursion:
(?R)✅ Supported - Conditionals: ✅ Supported
- Subroutines:
(?&name)✅ Supported
Java
- Lookahead/Lookbehind: ✅ Supported
- Named Groups:
(?<name>...)✅ Supported - Atomic Groups:
(?>...)✅ Supported - Possessive Quantifiers: ✅ Supported
- Unicode: Full Unicode support
.NET (C#)
- Balancing Groups:
(?<name1-name2>...)✅ Unique feature - Conditional:
(?(expression)yes|no)✅ Supported - Right-to-left:
RegexOptions.RightToLeft✅ Supported - Most Features: Very comprehensive
Key Differences Summary
| Feature | JavaScript | Python | PCRE | Java | .NET |
|---|---|---|---|---|---|
| Lookbehind | ✅ | ✅ | ✅ | ✅ | ✅ |
| Named Groups | ✅ | ✅ | ✅ | ✅ | ✅ |
| Atomic Groups | ❌ | ❌ | ✅ | ✅ | ✅ |
| Possessive Quantifiers | ❌ | ❌ | ✅ | ✅ | ✅ |
| Recursion | ❌ | ❌ | ✅ | ❌ | ❌ |
| Balancing Groups | ❌ | ❌ | ❌ | ❌ | ✅ |
Recommendations
- For testing JavaScript patterns: Use this tool
- For Python patterns: Test with
python3 -c "import re; ..." - For PCRE patterns: Use
grep -Por regex101.com - For production: Always test in your target language/environment