I'm trying to work on a regular expression I've found and make it work with my requirements. I have already modified the regular expression slightly to suit some of my requirements. However, I need help to implement some of the conditions. The email is divided into 3 parts:
- the local part (before the last
@); - the last
@symbol; and - the domain part (after the
@).
The regular expression that I have so far is:
/^([a-zA-Z0-9!#\$%&\'\*\+-\/=\?\^_`{\|}~]{1,64})@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
The local part of the email address shall only contains the following special characters: . " ( ) , : ; < > @ [ \ ].
An . in the local part of the email address should not be the first or last characters of the local part.
The condition for ( ) , : ; < > @ [ ] to be displayed in the local part of an email address is ( ) , : ; < > @ [ ] shall be contained between quotation marks.
In the local part of the email address, " and \ shall be preceded with a backslash (i.e. \" or \).
Each part of the domain shall be separated by a period, and the domain part of an email shall be less than 256 characters.