regexvalidationemail

RegEx for validating emails


I searched this site and found many threads that deal with this topic. But don't know why none of them realized that email formats vary a lot and not limited to xxx@ddd.com or something like this as for example xxxx@ddddd.rr.com is valid email address and so is xxx@ddd.museum . I tried almost all regular expressions that can be found for validating emails, none worked for this validation. Then there are emails with .info, .museum, etc.

I am very poor at regular expressions. Just wondering if someone can write a very broad express that checks for "at least one @ and one or more dots, no comma). I understand it will not work perfectly but at least it will not reject valid email addresses.


Solution

  • My best bet is \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*. This rocks.

    Its official Microsoft's email regex, which i got from my visual studio ultimate 2013 :)