I'm working on a regex for email verification.
This is what I have so far:
(?!^.*([._%+$-])\1+.*$)^[a-zA-Z0-9][a-zA-Z0-9._%+$-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,7}$
I've gotten it to fulfill all these requirements:
- Consecutive periods (note, multiple periods can occur in address, they have to be separated by valid characters). Example customer@yahoo..com
- User names starting with a special character. Example #customer@yahoo.com
- User names with two special characters in a row. Example cu$$tomer@yahoo.com
- Suffix name minimum length is 2. Example of invalid length: customer@yahoo.c
- Suffix maximum length is 7. Example of invalid length: customer@yahoo.commmmmmm
But I am stuck on this last one:
- User name special character cannot follow period. Example customer.name.#name2@yahoo.com
I've attempted to add a second negative lookahead like this but I can't get it to work correctly.:
(?!^.*([._%+-])\1+.*$)(?!^.*(.)\2+([._%+-])$)^[a-zA-Z0-9][a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,7}$
Any help is MUCH appreciated!