Welcome to RegEx Snippets

RegEx Snippets is your go-to resource for ready-to-use regular expressions for common validation tasks. Whether you need to validate emails, phone numbers, social security numbers, zip codes, file paths, domains, or URLs, we've got you covered with well-tested and optimized regex patterns.

What You'll Find Here

  • Comprehensive Regex Snippets - Predefined patterns for various validation scenarios.
  • Multi-Language Examples - Implementation guides for HTML5, JavaScript, Rust, and more.
  • Clear Explanations - Breakdown of regex patterns to help you understand how they work.
  • Consistent Formatting - Easy-to-read code snippets with best practices in mind.

Why Use RegEx Snippets?

  • Save Time - No need to write regex from scratch; use reliable, battle-tested patterns.
  • Improve Accuracy - Avoid common pitfalls and errors in regex validation.
  • Cross-Language Support - Apply regex solutions in different programming environments.

Automated Testing

All regex patterns in this repository are rigorously tested to ensure accuracy and reliability. Each pattern includes a comprehensive test suite that validates against the exact test cases shown in the table for that pattern. The tests are currently implemented in TypeScript using Bun's test framework. You can view the complete test suite in our GitHub repository, where every pattern is verified against both valid and invalid inputs to ensure consistent behavior.