Email pattern validation w3schools
According to W3Schools, the email pattern validation is as follows:
Email Pattern:
The email pattern is a regular expression that checks if the input string matches the format of an email address.
Here is the email pattern:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Let's break it down:
^
matches the start of the string[a-zA-Z0-9._%+-]+
matches one or more of the following characters: letters (both uppercase and lowercase), numbers, dot (.), hyphen (-), underscore (_), percent (%), plus sign (+)@
matches the @ symbol[a-zA-Z0-9.-]+
matches one or more of the following characters: letters (both uppercase and lowercase), numbers, dot (.), hyphen (-)\.
matches a period (.) character[a-zA-Z]{2,}
matches the domain extension (it must be at least 2 characters long and only contain letters)$
matches the end of the string
Example:
Here are some examples of valid and invalid email addresses using this pattern:
Valid email addresses:
Invalid email addresses:
- @example.com (missing local part)
- example..com (multiple dots in local part)
- [email protected] (missing domain extension)
- example@gmail (missing @ symbol)
Note:
This pattern does not validate if the email address actually exists or is in use. It only checks if the input string matches the format of an email address.
Also, this pattern is not foolproof and may not catch all invalid email addresses. For example, it does not check for invalid characters in the local part or domain name.