Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression for email validation. [duplicate]

Possible Duplicate:
What is the best regular expression for validating email addresses?

I'm using a form which ask for email address. I used regular expression for it as

.*@.*\..*

But it is not working fine for some of my test email id like

dsrasdf@@@[email protected]

Any one provide me regular expression for the email validation in asp.net or can i use any other method for it.

Please give your suggestions.

like image 611
Nagarajan Ganesh Avatar asked Nov 20 '25 21:11

Nagarajan Ganesh


2 Answers

Best to rely on the framework for this kind of stuff.

try {
    address = new MailAddress(address).Address;
} catch(FormatException) {
    //address is invalid
}
like image 65
Vinzz Avatar answered Nov 22 '25 11:11

Vinzz


I am using the following regular expression for my email validations (case insensitive):

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

I do not know about asp, but i think that you can use it like this.

like image 26
jwueller Avatar answered Nov 22 '25 11:11

jwueller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!