Regex Collection - Regex Collection Online

Summary of commonly used Regex

Email

Validate email address

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

URL

Validate URL

^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w .-]*)*\/?$

Phone (VN)

Vietnam phone number

^(0|\+84)(3|5|7|8|9)[0-9]{8}$

Phone (US)

US phone number

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

IPv4

IPv4 address

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

IPv6

IPv6 address

^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$

Date (YYYY-MM-DD)

ISO date format

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

Date (DD/MM/YYYY)

Vietnamese date format

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

Time (HH:MM)

24-hour time

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

Hex Color

Hex color code

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Username

3-16 chars, alphanumeric + underscore

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

Password (Strong)

Min 8 chars, upper, lower, number, special

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

Credit Card

Visa, Mastercard, Amex

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

CMND/CCCD

ID card (9 numbers) or CCCD (12 numbers)

^[0-9]{9}$|^[0-9]{12}$

Slug

URL-friendly slug

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

HTML Tag

Match HTML tags

<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)

YouTube URL

YouTube video URL

^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+$

MAC Address

MAC address

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

UUID

UUID v4

^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$

Vietnamese Name

Vietnamese names with capitalized words

^[A-Z][a-z]+(?:\s[A-Z][a-z]+)*$

20 patterns

Regex Collection - Collection of 20+ Most Popular Regular Expression Patterns

Collection of 20+ most popular regex patterns for developers. Email validation, URL, Phone (Vietnam & US), IPv4, IPv6, Date formats (ISO & VN), Time, Hex Color, Username, Strong Password, Credit Card (Visa, Mastercard, Amex), ID/CCCD, Slug, HTML Tag, YouTube URL, MAC Address, UUID, Vietnamese Name. Copy pattern with one click. Test regex directly with input of you. All patterns have been tested and widely used in production.

Outstanding features

20+ most common regex patterns tested
Email validation - RFC compliant pattern
URL validation - http, https, with path
Phone: Vietnam (10-11 numbers)andUS format
IP Address: IPv4 and IPv6 patterns
Date: ISO format (YYYY-MM-DD) and VN format (DD/MM/YYYY)
Time: 24-hour format (HH:MM)
Hex Color: 3 and 6 characters
Username: alphanumeric + underscore, 3-16 chars
Strong Password: uppercase, lowercase, number, special char
Credit Card: Visa, Mastercard, Amex
ID card/CCCD: 9 numbers (ID card)or 12 numbers (CCCD)
Slug: URL-friendly format
HTML Tag: match openingandclosing tags
YouTube URL: youtube.com and youtube.be
MAC Address: colonandhyphen separated
UUID: version 4 format
Vietnamese Name: full accented name
Search to filter patterns
Test regex directly with input of you
Copy pattern with one click

Why do we need Regex Collection?

Writing a Regular Expression from scratch is time-consuming and easy to get wrong. A simple regex like email validation can take hours to write correctly and cover edge cases. This collection compiles regexes that have been thoroughly tested and widely used in production by thousands of developers. You just need to: Search for the pattern you need, Test with data that of you right on the page, Copy and paste ando the code. Save hours debugging regex and avoid bugs from patterns don't complete. Especially useful Useful for form validation, data parsing, input sanitization.

Benefits when used

  • Save time - no need to write regex from scratch
  • Tested - patterns have been verified with many edge cases
  • Production-ready - used in real applications
  • Localized - has patterns for Vietnam (phone, ID card, name with accents)
  • Learn regex - see patterns to learn how to write regex
  • Quick reference - bookmark pages for quick reference

How to use Regex Collection

  1. 1Use the Search box to find the pattern you want to use (for example: 'email', 'phone', 'date')
  2. 2See a list of matching patterns with short descriptions
  3. 3Enter text in the 'Enter text to test regex' box to test the pattern
  4. 4Each pattern will display 'Match' (green) or 'No match' (red).
  5. 5Click the Copy button to copy the pattern to clipboard
  6. 6Paste the pattern into your code
  7. 7In JavaScript: new RegExp(pattern) or /pattern/flags
  8. 8Adjust pattern if needed (add ^$ for exact match, add flags)

Frequently Asked Questions (FAQ)

Does this regex work in other languages?

Most patterns are standard regex syntax, working in JavaScript, Python, PHP, Java, C#, Ruby, Go. However, some features may be different: JavaScript does not have lookbehind in ES5 (since ES2018). Python uses the re module with similar syntax. PHP uses preg_match with delimiters. You should test patterns in the target language.

Why email regex don't match email of me?

The email regex in the collection is a simplified version, covering 99% of cases. RFC 5322 compliant email regex is very complex (hundreds of characters). If email does not match: Check for unusual special characters. Check if the TLD (domain extension) is valid. In production, you should combine regex with email verification (send confirmation link).

Does Phone VN regex match all phone numbers?

Pattern match for Vietnamese mobile phone numbers: starts with 0 or +84, followed by 3/5/7/8/9 (carrier prefix), then 8 numbers. Does not match: fixed numbers (with area code), hotline numbers (1800, 1900), other international numbers. Adjust pattern if you need to match more formats.

Is strong password regex secure enough?

Pattern requires: at least 8 characters, uppercase, lowercase, number, special character. This is a good baseline. However, password security depends on: not using common passwords, not containing username/email, high enough entropy. You should combine regex with password strength library like zxcvbn.

How to add ^ and $ to pattern?

Patterns in the collection do not have ^ (start) and $ (end) anchors to be more flexible. If you need an exact match (the entire string must match): Add ^ at the beginning and $ at the end. For example: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$ for an exact match email. Without anchors, the regex will match the substring.

Can credit card regex validate real card numbers?

Regex only validates the format (number of digits, prefix of Visa/Mastercard/Amex). Do not validate: Luhn checksum (last digit), Does the card exist, Is the card still valid? To validate a real card, you need: Regex check format, Luhn algorithm check, API call to payment processor.

How does Vietnamese Name regex work?

Pattern match Vietnamese names with accents: Each word starts with an uppercase letter (accented), followed by a lowercase letter (accented), words separated by spaces. Match: 'Nguyen Van An', 'Tran Thi Bich Ngoc'. No match: 'Nguyen van An' (missing capital), 'NGUYEN VAN AN' (all caps), 'Nguyen Van An' (missing diacritics).

Can I request more patterns?

This collection covers the most popular patterns. If you need a special pattern, you can: Use the Regex Debugger tool to write and test it yourself. Search online for specific patterns. Combine multiple patterns. Most validation cases can be derived from existing patterns.

Related keywords

regex collectionregex patternsregular expression examplesemail regexphone regex vietnampassword regexurl regexdate regexcommon regex patternsregex cheat sheet

Cooperate immediately with Mavis Digital

We not only design websites, but also help businesses build strong digital brands. Providing comprehensive website design services from design to SEO optimization. Please contact Mavis Digital immediately to create breakthrough, effective and sustainable technology solutions for your business in Ho Chi Minh.

Tools Developer Tools related