Tan Phat Digital

Regex Collection Online Free

20 common regular expressions — copy, test, and use instantly

Email Address

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

Example: user@example.com

URL (http/https)

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

Example: https://example.com/path

Phone (US)

Validation
^(\+1)?[-.\s]?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$

Example: (555) 123-4567

IPv4 Address

Network
^((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]?)$

Example: 192.168.1.1

Date (YYYY-MM-DD)

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

Example: 2024-01-15

Time (HH:MM)

Date/Time
^([01]?[0-9]|2[0-3]):[0-5][0-9]$

Example: 14:30

Hex Color

Design
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

Example: #FF5733

Strong Password

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

Example: P@ssw0rd!

Credit Card

Finance
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11})$

Example: 4111111111111111

ZIP Code (US)

Validation
^\d{5}(-\d{4})?$

Example: 12345 or 12345-6789

Username (alphanumeric)

Validation
^[a-zA-Z0-9_]{3,20}$

Example: user_name123

Slug (URL-friendly)

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

Example: my-blog-post

HTML Tag

Web
<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>

Example: <div class='test'>content</div>

JWT Token

Security
^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$

Example: eyJ...header.payload.signature

Semantic Version

Developer
^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$

Example: 1.2.3 or 2.0.0-beta.1

MAC Address

Network
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$

Example: 00:1A:2B:3C:4D:5E

Positive Integer

Numbers
^[1-9]\d*$

Example: 42

Decimal Number

Numbers
^-?\d+(\.\d+)?$

Example: -3.14

YouTube URL

Web
^(https?:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([\w-]{11})

Example: https://youtube.com/watch?v=dQw4w9WgXcQ

Base64 String

Developer
^[A-Za-z0-9+/]*={0,2}$

Example: SGVsbG8gV29ybGQ=

Regex Collection Online Free - Common Regular Expressions Library

Browse 20 common regular expressions online free. Copy patterns for email, URL, phone, password, IP address, date, hex color, credit card, JWT, and more. Test each pattern against your own input with instant match/no-match feedback. Filter by category (Validation, Security, Network, etc.) or search by name. All patterns are battle-tested and production-ready.

Key Features

20 common regex patterns
Filter by category (Validation, Security, Network, etc.)
Search patterns by name
Test patterns with custom input
Instant match/no-match feedback
Copy pattern with one click
Pattern description and example
Works with JavaScript regex syntax
Free, no registration required

Why Use a Regex Collection?

Writing regex from scratch is time-consuming and error-prone. A single misplaced character can cause security vulnerabilities (like allowing invalid emails) or false positives (rejecting valid input). This collection provides battle-tested patterns for the most common validation needs. Each pattern has been verified against real-world inputs. Using proven patterns saves development time and prevents bugs in form validation, data parsing, and input sanitization.

Benefits

  • Save time writing regex from scratch
  • Use battle-tested, production-ready patterns
  • Test patterns against your own input instantly
  • Learn regex by studying real-world examples
  • Prevent security vulnerabilities from bad validation
  • Copy and use patterns directly in your code

How to Use the Regex Collection

  1. 1Browse the pattern cards or use the search box
  2. 2Filter by category to find relevant patterns
  3. 3Read the pattern description and example
  4. 4Click the copy button to copy the regex pattern
  5. 5Test the pattern by typing in the test input field
  6. 6See instant match/no-match feedback as you type

How to Use Regex in Different Languages

JavaScript: new RegExp(pattern).test(input) or /pattern/.test(input). Python: import re; re.match(pattern, input). PHP: preg_match('/pattern/', input). Java: Pattern.compile(pattern).matcher(input).matches(). C#: Regex.IsMatch(input, pattern). Most patterns in this collection use standard regex syntax compatible with all these languages. Some patterns may need minor adjustments for language-specific syntax.

Frequently Asked Questions

Are these patterns production-ready?

Yes, these are commonly used patterns. However, always test with your specific use case as requirements may vary.

How do I use a regex in JavaScript?

Use new RegExp(pattern).test(input) or /pattern/.test(input). For example: /^[a-z]+$/.test('hello') returns true.

What does ^ and $ mean in regex?

^ means 'start of string' and $ means 'end of string'. Together they ensure the entire string matches the pattern, not just a part of it.

How do I make a regex case-insensitive?

Add the 'i' flag: new RegExp(pattern, 'i') or /pattern/i. This makes the pattern match both uppercase and lowercase letters.

Can I test my own regex patterns?

Yes, use the test input field below each pattern to test it against your own input. A green 'Match' or red 'No match' indicator shows the result.

Related Keywords

regex collectioncommon regex patternsregular expression libraryregex examplesregex cheatsheetregex patterns onlinevalidation regexregex reference guide

Hợp tác ngay với Tấn Phát Digital

Chúng tôi không chỉ thiết kế website, mà còn giúp doanh nghiệp xây dựng thương hiệu số mạnh mẽ. Cung cấp dịch vụ thiết kế website trọn gói từ thiết kế đến tối ưu SEO. Hãy liên hệ ngay với Tấn Phát Digital để cùng tạo nên những giải pháp công nghệ đột phá, hiệu quả và bền vững cho doanh nghiệp của bạn tại Hồ Chí Minh.

Công cụ Developer Tools liên quan

Zalo
Facebook
Tan Phat Digital
Zalo
Facebook