How to Use
The regexes below can be copied directly. It’s recommended to paste them into the Regex Tester and validate against your real data before using them. The examples don’t include start/end anchors by default; add ^ and $ at both ends when doing whole-string validation.
[\w.+-]+@[\w-]+\.[\w.-]+
A lenient, good-enough version. For whole-string validation, add anchors: ^[\w.+-]+@[\w-]+\.[\w.-]+$.
Phone Number (Mainland China)
1[3-9]\d{9}
Starts with 1, the second digit is 3-9, 11 digits total. For whole-string validation: ^1[3-9]\d{9}$.
URL
https?://[^\s]+
Matches http/https links. For stricter matching, restrict the domain and path characters.
IPv4 Address
\b(?:\d{1,3}\.){3}\d{1,3}\b
Note: this only validates the “four groups of digits” format; it does not guarantee each group is ≤ 255.
ID Number (Mainland China, 18 digits)
\d{17}[\dXx]
17 leading digits + a final digit or X. Whole-string: ^\d{17}[\dXx]$.
Date (YYYY-MM-DD)
\d{4}-\d{2}-\d{2}
E.g. 2026-07-02.
Chinese Characters
[一-龥]+
Matches a run of consecutive Chinese characters.
Numbers (Including Negatives and Decimals)
-?\d+(?:\.\d+)?
Matches 42, -3.14, etc.
Password Strength (At Least 8 Characters, with Upper- and Lowercase Letters and Digits)
(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}
Uses three lookaheads to require a lowercase letter, an uppercase letter, and a digit respectively. Add ^...$ for whole-string validation.
HTML Tag
<([a-zA-Z][\w-]*)[^>]*>
Matches an opening tag and captures the tag name. For parsing complex HTML, it’s still recommended to use a dedicated parser rather than a regex.
Keep Learning
- Don’t understand the symbols above: read What Is a Regular Expression;
- Want to learn to write your own: read How to Write a Regular Expression;
- The regex you copied doesn’t match: read What to Do When a Regex Doesn’t Match.