HeoLab
ToolsBlogAboutContact
HeoLab

Free developer tools with AI enhancement. Built for developers who ship.

Tools

  • JSON Formatter
  • JWT Decoder
  • Base64 Encoder
  • Timestamp Converter
  • Regex Tester
  • All Tools →

Resources

  • Blog
  • What is JSON?
  • JWT Deep Dive
  • Base64 Explained

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 HeoLab. All rights reserved.

Tools work in your browser. Zero data retention.

HomeBlog10 Regex Patterns Every Developer Should Know
Table of Contents▾
  • Table of Contents
  • 1. Email Address
  • 2. URL
  • 3. Phone Number (US)
  • 4. Strong Password
  • 5. IPv4 Address
  • 6. Date (YYYY-MM-DD)
  • 7. URL Slug
  • 8. Hex Color
  • 9. UUID (v4)
  • 10. Credit Card (basic)
tools#regex#patterns#validation

10 Regex Patterns Every Developer Should Know

Production-ready regular expressions for email, URL, phone, password, IP address, and more — with explanations.

Trong Ngo
February 22, 2026
1 min read

Table of Contents

  • 1. Email Address
  • 2. URL
  • 3. Phone Number
  • 4. Strong Password
  • 5. IPv4 Address
  • 6. Date (YYYY-MM-DD)
  • 7. URL Slug
  • 8. Hex Color
  • 9. UUID
  • 10. Credit Card

1. Email Address

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

Matches: user@example.com, test.name+tag@sub.domain.co.uk

2. URL

/^https?:\/\/[^\s/$.?#].[^\s]*$/i

For strict URL parsing, use new URL(str) and catch the error instead.

3. Phone Number (US)

/^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/

Matches: (555) 123-4567, 555.123.4567, +15551234567

4. Strong Password

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/

Requires: 8+ chars, one lowercase, one uppercase, one digit, one special character.

5. IPv4 Address

/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/

6. Date (YYYY-MM-DD)

/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/

7. URL Slug

/^[a-z0-9]+(?:-[a-z0-9]+)*$/

Matches: hello-world, my-post-2025

8. Hex Color

/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i

Matches: #fff, #ff5733, #ff573380 (with alpha)

9. UUID (v4)

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

10. Credit Card (basic)

/^(?:4\d{12}(?:\d{3})?|5[1-5]\d{14}|3[47]\d{13})$/

Detects Visa (4), Mastercard (51–55), Amex (34/37). Use Stripe in production.

Test all patterns with the Regex Tester.

Try These Tools

Regex Tester & Debugger

Test regular expressions against strings in real-time. Visualize matches, groups, and flags.

Related Articles

Mastering Regex Lookahead and Lookbehind

2 min read

How to Write Efficient Regular Expressions

2 min read

Using Regex for Form Validation: Patterns and Pitfalls

2 min read

Back to Blog

Table of Contents

  • Table of Contents
  • 1. Email Address
  • 2. URL
  • 3. Phone Number (US)
  • 4. Strong Password
  • 5. IPv4 Address
  • 6. Date (YYYY-MM-DD)
  • 7. URL Slug
  • 8. Hex Color
  • 9. UUID (v4)
  • 10. Credit Card (basic)

Related Articles

Mastering Regex Lookahead and Lookbehind

2 min read

How to Write Efficient Regular Expressions

2 min read

Using Regex for Form Validation: Patterns and Pitfalls

2 min read