c# - Regular expression for multiple email destinations delimited by semicolon -
i succeed regular expression single email this:
private readonly regex _regex = new regex(@"^[_a-za-z0-9-\\+]+(\\.[_a-za-z0-9-]+)*@" + "[a-za-z0-9-]+(\\.[a-za-z0-9]+)*(\\.[a-za-z]{2,})$");
now, need make regular expression more 1 email, , delimited semicolon
test@gmail.com;test2@yahoo.com;test3@gmail.com
i found regular expression:
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*
but problem regular expression "receive" string:
h@kj.com;asds@gmail
how can that?
thanks
let's not build regular expression more 1 because 1 complex enough, validate them individually:
foreach (var email in emaillist.split(new char[] { ';' }, stringsplitoptions.removeemptyentries)) { // validate email }
further, regular expressions aren't suited because user have put space, more 1 space, before or after semicolon - gets messy - , emails messy enough already.
Comments
Post a Comment