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@@@fer@hbdf.vjif
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.
Best to rely on the framework for this kind of stuff.
try {
address = new MailAddress(address).Address;
} catch(FormatException) {
//address is invalid
}
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.
^([\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})(\]?)$
精彩评论