I have written this regex to validate an email address. The rules I have to follow are:
The recipient name may be a maximum of 64 characters long and consist of:
- Uppercase and lowercase letters in English (A-Z, a-z)
- Digits from 0 to 9
- Special characters
- A special character cannot appear as the first or last character in an email address or appear consecutively two or more times
[a-zA-z0-9]{1}?![a-zA-z0-9]?[a-zA-z0-9]{1,63}@[a-zA-z0-9]+\.[a-zA-z0-9]+
I am obviously new to Regex. What I meant by this line was, the first character has to be one of the [a-zA-z0-9]
then, it is optional to use any special character by negating the [a-zA-z0-9]
and then again use [a-zA-z0-9]
before @.
Please help me to fulfil the above expectations.
Tnx