Regular expression for email authentication.

Possible duplicate:
What is the best regular expression for checking email addresses?

I am using a form that requests an email address. I used regex for it as

.*@.*\..*

But it does not work fine for my test email id, e.g.

dsrasdf @@@ fer@hbdf.vjif

Any of them provides me with a regular expression for checking email in asp.net or I can use some other method for this.

Please give your suggestions.

+3
source share
3 answers

.

try {
    address = new MailAddress(address).Address;
} catch(FormatException) {
    //address is invalid
}
+5

( ):

^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$

asp, , .

+1
^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z{2-4}|[0-9]{1,3})(\]?)$
0
source

Source: https://habr.com/ru/post/1763580/


All Articles