samedi 9 mai 2015

Match an email address if it contains a dot

I want to match any email address, that contains at least one . (dot) before the @ sign. The emails have already been validated, so the regex just needs to search for the ..

I have tried

Regex emailMatcher = new Regex(@"^[a-zA-Z\.']{1,}\.[a-zA-Z\.']{1,}@example\.com$");

But I know that emails can contain more characters than just a-zA-Z\.' so this won't cover all cases.

Any ideas on how to do it?

Thanks

EDIT: I'm not trying to validate emails, I already have the emails validated, I just need to select emails, that contain . before @ sign

Examples that would pass:

first.last@example.com
first.middle.last@example.com

Examples that should pass, but wouldn't pass using my current regex

first.last(comment)@example.com

Aucun commentaire:

Enregistrer un commentaire