Regex Tester

Test and debug regular expressions with instant matching feedback.

Settings

Test String

Results

About Regular Expressions

What is Regex?

Regular expressions (regex or regexp) are patterns used to match, find, and manipulate text. They consist of a sequence of characters defining a search pattern. First formalized in the 1950s by Stephen Kleene, regex is now a standard feature in virtually every programming language and text editor (JavaScript, Python, Java, Perl, etc.).

Common Use Cases

  • Email Validation: Verify user email addresses during registration
  • URL Matching: Extract URLs from text or validate URL formats
  • Phone Numbers: Match and format international phone numbers
  • Password Rules: Enforce complexity requirements (uppercase, numbers, symbols)
  • Find & Replace: Bulk text replacements in code editors
  • Log Analysis: Extract specific information from application logs

Real-World Examples

  • Email Pattern: ^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$ → Matches valid emails
  • Phone Pattern: ^\\d{3}-\\d{3}-\\d{4}$ → Matches ###-###-####
  • URL Pattern: https?://[^\\s]+ → Matches HTTP/HTTPS URLs
  • Hex Color: ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ → Matches color codes

Regex Components

  • \\d = digits (0-9)
  • \\w = word characters (a-z, A-Z, 0-9, _)
  • \\s = whitespace (spaces, tabs, newlines)
  • . = any character (except newline)
  • * = 0 or more times
  • + = 1 or more times
  • ? = 0 or 1 time