Regex Validation Examples
Regex Validation Examples
This page provides common regular expressions (Regex) used for validating various types of inputs along with examples of valid and invalid cases.
| Validation Type | Regex | Valid Examples | Invalid Examples |
|---|---|---|---|
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ |
|
|
|
| Phone Number (Vietnam) | ^(0|\+84)(3|5|7|8|9)\d{8}$ |
|
|
| Strong Password | ^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$ |
|
|
| Integer (Whole Numbers) | ^-?\d+$ |
|
|
| Real Numbers | ^-?\d+(\.\d+)?$ |
|
|
| Letters Only | ^[A-Za-z]+$ |
|
|
| IPv4 Address | ^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$ |
|
|
| Date (dd/mm/yyyy) | ^(0[1-9]|[12][0-9]|3[01])[-/](0[1-9]|1[0-2])[-/](19|20)\d{2}$ |
|
|
| Postal Code (Vietnam) | ^\d{6}$ |
|
|
| Person Name (with Vietnamese support) | ^[A-Za-zÀ-ỹà -ỹ\s]{1,50}$ |
|
|
| Letters | [a-zA-Z]+ |
|
|

Join the conversation