I have looked through questions asked in Stack Overflow to answer my question, but haven’t come up with a solution. I am needing to validate email addresses with the Amazon email service validation in mind. Here are the rules I am trying to follow:
- Dash cannot be preceded or followed by a period. Example:
.-
or-.
- Dash cannot be at the beginning of the domain. Example:
grant.fox@-abcfinancial.com
- Dash cannot be at the end of the domain. Example:
grant.hill@abc.com-
So far this is what I have come up with:
/^[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9]))+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.[A-Z]{2,6}$/