What do the flags mean?
- g (global): Doesn't stop at the first match β finds all matches in the whole text.
- i (ignore case): Case-insensitive matching.
- m (multiline): Makes ^ and $ match the start and end of each line, not just the whole string.
- s (dotAll): Makes . (dot) also match line-break characters.
Common regex examples
- Email:
[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,} - US phone number:
\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4} - URL:
https?:\/\/[\w.-]+\.[a-z]{2,}[\w\/?=-]* - Letters only:
[a-zA-Z]+ - Digits only:
\d+ - Collapse multiple spaces:
\s+
Notes
This tool uses JavaScript's own regular expression engine. The pattern and test string you enter are processed entirely in your browser and are never sent to a server. Some syntax (such as the extent of lookbehind support) may differ from other languages' regex engines, like Python's or PCRE.
Frequently Asked Questions
How do I check capture groups?
Using parentheses ( ) in your pattern creates a capture group. Click any match in the match list to see the full matched string along with the value extracted for each group.
What happens if my regex is invalid?
If there's a syntax error in your pattern, an error message appears in the status bar. Check that your parentheses and brackets are balanced, and that special characters are escaped with a backslash (\) where needed.