Regex Tester
Test and debug regular expressions
Enter your regular expression pattern without delimiters
Enter the text you want to test your regex pattern against
What is a Regex Tester?
A regex tester (regular expression tester) allows you to test and validate regular expression patterns against sample text. Regular expressions are powerful patterns used for matching, searching, and manipulating text. This tool helps you verify that your regex patterns work as expected before using them in your code.
How to Use
- Enter your regular expression pattern in the pattern field (without delimiters like /)
- Select any flags you need (g for global, i for case-insensitive, etc.)
- Enter or paste the text you want to test against in the test string field
- Click "Test Regex" to see all matches with their positions and capture groups
Example
Pattern:
\d3-\d3-\d4 Test string:
Call me at 555-123-4567 or 555-987-6543 With the "g" (global) flag, this will match both phone numbers and show their positions.
Supported Flags
- g (global): Find all matches rather than stopping after the first match
- i (ignore case): Case-insensitive matching
- m (multiline): ^ and $ match start/end of each line, not just the whole string
- s (dotAll): . matches newline characters
- u (unicode): Treat pattern as a sequence of Unicode code points
- y (sticky): Match only from the lastIndex position
Common Regex Patterns
- Email:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL:
https?://[^\s]+ - Phone (US):
\d{3}-\d{3}-\d{4} - Date (YYYY-MM-DD):
\d{4}-\d{2}-\d{2} - Hex Color:
#[0-9a-fA-F]{6} - IPv4 Address:
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
Technical Notes
This tool uses JavaScript's native RegExp engine, which follows the ECMAScript specification.
The tool includes safety limits to prevent browser freezes: it will stop after finding 10,000
matches and includes protection against infinite loops caused by zero-width matches (like
/(?:)/g).
For large inputs (over 10KB), the tool automatically uses a Web Worker to process the regex in a background thread, preventing the UI from freezing. Complex patterns are limited to a 5-second timeout to prevent infinite processing.
Privacy Notice
All regex testing happens entirely in your browser. Your patterns and test strings are never transmitted to any server, ensuring complete privacy for sensitive data.
Frequently Asked Questions
What's the difference between the g flag and no flag?
Without the "g" (global) flag, the regex will stop after finding the first match. With the "g" flag, it will continue searching and return all matches in the test string. For most testing purposes, you'll want to use the "g" flag to see all occurrences.
Why do I need to escape backslashes?
In regex patterns, backslashes are used for special sequences like \d (digit) or \s (whitespace). If you want to match a literal backslash, you need to escape it as \\. This is standard regex syntax, not specific to this tool.
What are capture groups?
Capture groups are parts of your regex pattern enclosed in parentheses. They allow you to
extract specific portions of a match. For example, in the pattern (\d3)-(\d3)-(\d4),
each set of parentheses creates a capture group that extracts the area code, prefix, and
line number separately.
Why does my pattern show "Too many matches"?
This tool has a safety limit of 10,000 matches to prevent browser freezes. If you see this
error, your pattern is likely too broad (like . with the g flag on a large
text). Try making your pattern more specific or testing with a smaller sample.
What are zero-width matches?
Zero-width matches are patterns that match a position rather than characters, like ^
(start of line) or \b (word boundary). Patterns like /(?:)/g can cause
infinite loops because they match every position without advancing. This tool includes
protection against such patterns.
Can I test regex for other programming languages?
This tool uses JavaScript's regex engine, which is similar to but not identical to regex engines in other languages. Most basic patterns work the same across languages, but advanced features like lookbehinds, named groups, or specific escape sequences may differ. Always test in your target language's environment for production use.
Why isn't my pattern matching?
Common issues include: forgetting the "g" flag for multiple matches, not escaping special characters, case sensitivity (use the "i" flag), or multiline issues (use the "m" flag). Check that your pattern syntax is correct and that you're using the appropriate flags for your use case.