🔍 Regex Test Tool

Test your regular expressions and see matches.

Do not use delimiters (/), they will be added automatically
Maximum 10,000 characters

🔍 What is Regex (Regular Expression)?

Regex (Regular Expression) is a powerful tool used to search, match, and replace specific patterns within text. With our online regex test tool, you can test your regular expressions and visually inspect the matches.

Basic Regex Characters

🔤 Character Classes

  • . - Any character
  • \d - Digit [0-9]
  • \w - Word character [a-zA-Z0-9_]
  • \s - Whitespace character

🔢 Quantifiers

  • * - 0 or more
  • + - 1 or more
  • ? - 0 or 1
  • {n,m} - Between n and m

⚓ Anchors

  • ^ - Start of line
  • $ - End of line
  • \b - Word boundary
  • \B - Not a word boundary

🎯 Groups

  • () - Capturing group
  • (?:) - Non-capturing group
  • [] - Character set
  • | - Alternation (OR)

Common Regex Examples

📧 Email Validation

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Matches valid email addresses

📱 Phone Number

(\+90|0)?[\s-]?5\d{2}[\s-]?\d{3}[\s-]?\d{2}[\s-]?\d{2}

Turkey mobile phone formats

🌐 URL Validation

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

Matches HTTP/HTTPS URLs

🔢 IP Address

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Validates IPv4 addresses

Regex Flags (Modifiers)

  • i (Case Insensitive): Case insensitive match
  • m (Multiline): ^ and $ apply to each line
  • s (Dotall): . character matches newline too
  • x (Extended): Ignore whitespaces and comments
  • u (Unicode): Unicode support enabled

Regex Use Cases

✅ Data Validation

  • Form validation
  • Email check
  • Password strength test
  • Phone number format

🔍 Text Processing

  • Search and replace
  • Log analysis
  • Data extraction
  • Text cleaning

🌐 Web Development

  • URL routing
  • HTML parsing
  • API validation
  • Input sanitization

📊 Data Analysis

  • CSV parsing
  • Log mining
  • Pattern detection
  • Data extraction

Regex Performance Tips

⚡ Optimization:

  • Be Specific: Use as narrow pattern as possible
  • Anchors: Use ^ and $ to specify start/end
  • Lazy Quantifiers: Use lazy (*?, +?) instead of greedy
  • Character Classes: Use \d instead of [0-9]

Common Regex Errors

⚠️ Points to Consider:

  • Catastrophic Backtracking: Complex patterns can cause performance issues
  • Escape Characters: Escape special characters with \
  • Greedy Matching: Consider using .*? instead of .*
  • Unicode: Use u flag for special characters

Regex Alternatives

🛠️ Other Options:

  • String Functions: strpos(), substr() for simple operations
  • Parser Libraries: Special parsers for complex formats
  • Validation Libraries: Ready-to-use libraries for form validation
  • Lexer/Parser: lex/yacc for programming languages
💡 Tip: Regex is a powerful tool but consider alternative solutions for complex cases. Validate your patterns with our test tool.