Regex Tester
Test and debug regular expressions online with visual match highlighting.
Regex Flags
What are Regular Expressions?
Regular expressions (regex) are powerful patterns used to match, search, and manipulate text. They provide a concise way to describe complex string patterns, making them essential for text processing, validation, and data extraction.
Basic Regex Syntax
- . - Matches any single character (except newline)
- ^ - Matches the start of a string
- $ - Matches the end of a string
- * - Matches zero or more of the preceding element
- + - Matches one or more of the preceding element
- ? - Matches zero or one of the preceding element
- [ ] - Character class, matches any one character inside
Regex Flags
- g (Global) - Find all matches, not just the first one
- i (Ignore Case) - Case-insensitive matching
- m (Multiline) - ^ and $ match line breaks
- s (Dot All) - . matches newline characters
- u (Unicode) - Enable Unicode property escapes
- y (Sticky) - Matches only from the lastIndex position
Common Regex Patterns
- Email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/
- URL: /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/
- Phone: /^\+?[1-9]\d{1,14}$/
- IP Address: /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/
- Date (YYYY-MM-DD): /^\d{4}-\d{2}-\d{2}$/