Regex Tester
Test and validate your regular expressions with real-time syntax highlighting and matching. Supports JavaScript regex syntax with live preview of matches.
Regular Expression Tester
Test and validate your regular expressions in real-time. Enter a pattern and test string to see matches, capture groups, and match positions. Use the flags to modify the matching behavior.
Basic Examples
Phone Number (US Format)
Pattern:
\(\d{3}\) \d{3}-\d{4} Test with:
(555) 123-4567 Email Address
Pattern:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} Test with:
user@example.com Capture Groups
Date Parsing
Pattern:
(\d{4})-(\d{2})-(\d{2}) Test with:
2024-03-15 This will capture year, month, and day in separate groups.
URL Parsing
Pattern:
(https?):\/\/([^\/]+)(\/[^\s]*)? Test with:
https://example.com/path/to/page This will capture protocol, domain, and path in separate groups.
Common Flags
Global (g)
Find all matches in the text, not just the first one.
Example with 'g' flag:
\b\w+\b Test: The quick brown fox Case Insensitive (i)
Match letters regardless of their case.
Example with 'i' flag:
hello Test: Hello HELLO hello Multiline (m)
Treat each line as a separate string for ^ and $ anchors.
Example with 'm' flag:
^\d+ Test:
123
456
789 Tips & Best Practices
-
Use
\bfor word boundaries -
Use
\dfor digits instead of[0-9] -
Use
\wfor word characters (letters, digits, underscore) -
Use
\sfor whitespace characters -
Use
^and$to match start and end of string -
Use
(?:...)for non-capturing groups -
Use
\to escape special characters -
When copying patterns, use single backslashes (e.g.
\d4), not double