Answer the question
In order to leave comments, you need to log in
How to exclude two dots from an email address using regexp?
There is a task:
Write a function that checks the e-mail entered by the user for compliance with the following rules:
1. e-mail consists of a name and a domain part, these parts are separated by the "@" character;
2. the domain part is not shorter than 3 characters and not longer than 256, is a set of non-empty strings consisting of the characters az 0-9_- and separated by a dot;
3. each component of the domain part cannot begin or end with the "-" character;
4. name (before @) no longer than 128 characters, consists of characters a-z0-9"._-;
5. two periods in a row are not allowed in the name;
6. if the name contains double quotes ", then they must be paired ;
7. characters "!,:" can occur in the name, but only between paired double quotes.
((?!-)[A-Z0-9"\.\-_]{1,128}(?<!-)@(?!-)[A-Z0-9\-_.]{3,256}(?<!-))
|(?:\.(?!\.))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question