Regex Examples Library
Rich regular expression template collection with one-click copy support
Email Address
Contact^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Matches standard email format, supports international domains
Phone Number
Contact^1[3-9]\d{9}$
Matches Chinese mainland phone numbers
ID Card
Identity^\d{17}[\dXx]$
Matches 18-digit ID card numbers, supports X ending
IP 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]?)$
Matches IPv4 address format
URL Link
Network^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$
Matches HTTP/HTTPS links
Date Format
Format^\d{4}-\d{2}-\d{2}$
Matches YYYY-MM-DD format date
Time Format
Format^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$
Matches HH:MM:SS format time
Chinese Characters
Text[\u4e00-\u9fa5]
Matches Chinese characters
Numbers and Letters
Text^[a-zA-Z0-9]+$
Matches strings containing only numbers and letters
Password Rule
Format^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$
Requires at least eight characters with letters and numbers.
Username
Text^[a-zA-Z0-9_]{3,20}$
Matches 3-20 character usernames with letters, numbers, and underscores.
Hex Color
Format^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
Matches CSS hex color values such as #fff or #1a73e8.
UUID
Identity^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
Matches common UUID versions 1-5 with standard hyphen groups.
URL Slug
Text^[a-z0-9]+(?:-[a-z0-9]+)*$
Matches lowercase URL slugs made from words separated by hyphens.
Domain Name
Network^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$
Matches simple domain names with one or more labels and a TLD.
File Extension
Format^.+\.(jpg|jpeg|png|gif|webp|pdf)$
Matches filenames with common image or PDF extensions.
How To Choose A Regex Example
Start with the closest template, then adjust it for your input format. Some examples are strict full-value validators, while others are better for finding text inside a longer document. Anchors such as `^` and `$` mean the entire string must match; removing them turns many validators into search patterns.
Pay attention to the regex engine used by your project. JavaScript, Python, Java, PHP, and database engines support many of the same basics but differ around Unicode classes, lookbehind, escaping, and named groups. Always test a template with real valid and invalid examples before using it in production.
JavaScript Regex Flags
Common JavaScript flags include `g` for global matching, `i` for case-insensitive matching, and `m` for multiline anchors. These flags can change the result even when the pattern text is unchanged, so test them deliberately in the Regex Tester.
Regex Examples FAQ
Can I copy these regex examples directly? Yes, but treat them as starting points. Adjust them for your exact rules and test them with edge cases.
Why are some examples strict? Validators often use anchors to require a full-string match. Search patterns are usually more flexible and may omit anchors.
Where should I test an example? Copy it into the Regex Tester or check syntax in the Regex Checker before using it.