Common Regex Pattern Library

Copy tested regex patterns for email, URL, dates, IPs, and more.

Regex Patterns for Common Validation Tasks

Writing correct regular expressions for common formats — email addresses, URLs, phone numbers, IP addresses, dates — is harder than it looks. Edge cases abound: emails can have + and dots before the @, IPv6 addresses look nothing like IPv4, and date formats vary by locale. Our pattern library gives you battle-tested patterns you can use immediately.

Each pattern in the library is tested against real-world inputs including edge cases. We document what each pattern matches and what it intentionally excludes, so you know the trade-offs. For example, a simple email regex is fast and covers 99% of cases, while the RFC 5321-compliant pattern is much more complex — we give you both.

Use our tester to verify any pattern against your specific inputs before putting it in production. Paste the pattern, add your test cases, and confirm the matches and rejections are what you expect. This prevents the classic mistake of deploying a regex that almost works.

Tips

  • For email validation, a simple pattern (/^[^\s@]+@[^\s@]+\.[^\s@]+$/) covers 99% of real cases. RFC-compliant patterns are rarely worth the complexity.
  • Never use regex for full URL parsing — use the URL API in browsers and Node.js instead.
  • Phone number validation is country-specific. Consider libphonenumber for international support.
  • Precompile regex patterns outside loops: const RE = /pattern/g at module scope, not inside a function.

Ready to get started?

Test Regex Patterns

New tools every week

Get notified. No spam.