Regex Tester

Test, debug, and experiment with regular expressions in real-time

Flags:
//gm
0 characters

Results

Common Patterns

Email address
Match standard email addresses
/\b[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}\b/
URL
Match URLs with http or https
/https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/
Phone number (US)
Match US phone numbers in various formats
/(?:\+1|\b)[-. ]?(?:\(\d{3}\)|\d{3})[-. ]?\d{3}[-. ]?\d{4}\b/
Date (MM/DD/YYYY)
Match dates in MM/DD/YYYY format
/\b(0?[1-9]|1[0-2])[\/\-](0?[1-9]|[12]\d|3[01])[\/\-](19|20)\d{2}\b/
IP address
Match IPv4 addresses
/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/
HTML tag
Match HTML tags with content
/<([a-z][a-z0-9]*)\b[^>]*>(?:.*?)<\/\1>/
Whitespace
Match one or more whitespace characters
/\s+/
Password strength
Match strong passwords (min 8 chars, uppercase, lowercase, number, special char)
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/

Regex Quick Reference

\dDigit
\wWord character
\sWhitespace
\bWord boundary
^Start of line
$End of line
[abc]Character set
(x|y)Alternation
x?Optional
x*0+ occurrences
x+1+ occurrences
x{n,m}n to m times
(x)Capture group

About Regular Expressions

Regular expressions (regex) are powerful patterns used to match character combinations in strings. They are used for input validation, search and replace operations, advanced text processing, and more.

Common Use Cases:

  • Validate email addresses, phone numbers, dates
  • Extract specific information from text
  • Find and replace text patterns
  • Sanitize user input
  • Parse and transform data formats
  • Identify patterns in large text datasets

Tips for Writing Regexes:

  • Start simple and add complexity gradually
  • Use non-capturing groups (?:...) for better performance
  • Be careful with greedy quantifiers (* and +)
  • Use word boundaries (\b) to match whole words
  • Test with various inputs including edge cases
  • Use named capture groups for readability

Regular expressions can be complex but are extremely powerful once understood. They follow standardized syntax rules that work across many programming languages with slight variations.