Answer the question
In order to leave comments, you need to log in
Is it a good regular expression to search for email addresses?
Hello, please tell me, I made the following regular expression:
([a-zа-яё0-9._-]+)(@{1})([a-zа-яё0-9._-]+)\.([a-zа-я]{2,3})
Answer the question
In order to leave comments, you need to log in
In fact, seriously, it is impossible to create such a regexp. The problem is that there is no single rule for validating email addresses. Any [email protected] address can be an email address or something else. For example XMPP user (JID).
Here is an example of a more or less suitable regular expression for email:
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question