Email regex
Validate and extract common email address formats.
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Tips
- Supports Gmail-style plus aliases.
- Domain part allows nested subdomains.
- Does not match addresses missing @ or a domain.
- For strict validation, also check on the server.
Phone regex
Match 11-digit mainland China mobile numbers.
1[3-9]\d{9}
Tips
- Matches 11 digits starting with 1.
- Second digit is 3–9 (all carriers).
- Does not match landlines or short numbers.
- Optional country code form: (?:(?:\+|00)86)?1[3-9]\d{9}
URL regex
Match HTTP and HTTPS links.
https?://[\w\-._~:/?#\[\]@!$&'()*+,;=%]+
Tips
- Matches both http and https.
- Allows query strings and fragments.
- Supports ports such as :8080.
- Does not match ftp; use \w+:// if needed.
IP regex
Match IPv4 addresses (0.0.0.0 – 255.255.255.255).
(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)
Tips
- Each octet is validated in 0–255.
- Values such as 256 are rejected.
- IPv6 needs a separate, longer pattern.
- Use word boundaries to avoid matching version numbers.
Date regex
Match ISO dates in YYYY-MM-DD form.
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
Tips
- Month is limited to 01–12.
- Day is limited to 01–31.
- Does not check calendar rules such as Feb 30.
- Change the separator for DD/MM/YYYY and similar formats.