Summary of commonly used Regex
Validate email address
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Validate URL
^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w .-]*)*\/?$Vietnam phone number
^(0|\+84)(3|5|7|8|9)[0-9]{8}$US phone number
^\+?1?[-.\s]?\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$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 address
^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$ISO date format
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$Vietnamese date format
^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/\d{4}$24-hour time
^([01]?[0-9]|2[0-3]):[0-5][0-9]$Hex color code
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$3-16 chars, alphanumeric + underscore
^[a-zA-Z0-9_]{3,16}$Min 8 chars, upper, lower, number, special
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Visa, Mastercard, Amex
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$ID card (9 numbers) or CCCD (12 numbers)
^[0-9]{9}$|^[0-9]{12}$URL-friendly slug
^[a-z0-9]+(?:-[a-z0-9]+)*$Match HTML tags
<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)YouTube video URL
^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+$MAC address
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$UUID v4
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$Vietnamese names with capitalized words
^[A-Z][a-z]+(?:\s[A-Z][a-z]+)*$20 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.
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.
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.
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).
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.
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.
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.
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.
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).
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.
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.
Create .envand.env.example file for project.
Generate .gitignore for Node.js, Python, Java.
Create mock JSON data for API testing.
Format and analyze API response.
Test REST API: GET, POST, PUT, DELETE.
Convert Binary, Hex, Base32.
Base64 encoding/decoding.
Convert Decimal, Binary, Hex.
Create visual CSS box-shadow.
Calculate Linux file permissions.
Check WCAG accessibility.
Generate random color palette.