Regular expression for validating email
: Finally, the email address must end with two to four alphabets.
Having a-z and A-Z means that both lowercase and uppercase letters are allowed.
[email protected] – “.a” is not a valid tld, last tld must contains at least two characters 4. mkyong()*@– email’s is only allow character, digit, underscore and dash 8.
[email protected]– email’s first character can not start with dot “.” 7.
Before starting it, first we have to know something about Regular Expressions. A regular expression is a unique text string for representing a search pattern.
These are the relevant elements which helps to create a proper Reg Ex patterb for email validation.On the final line we call test method for our regular expression and pass the email address as input.If the input email address satisfies our regular expression, ‘test’ will return true otherwise it will return false. You can call this method whenever you want to validate email address.We can validate email address at client side and server side.To validate email address on client side, we can use java script with regular expression.