Q:

Regular expression for multiple email destinations delimited by semicolon

I succeed to do regular expression for single email like 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, I need to make regular expression for more than one email, and delimited by semicolon
test@gmail.com;test2@yahoo.com;test3@gmail.com

I found this regular expression:
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

but the problem that this regular expression also "receive" this string:
h@kj.com;asds@gmail

How can I do that?
Thanks

A:

Let's not build a regular expression for more than one because this one is complex enough, just validate them individually:
foreach (var email in emailList.Split(new char[] { ';' },
    StringSplitOptions.RemoveEmptyEntries))
{
    // validate email
}

further, regular expressions aren't all that well suited for something like this because the user could have put a space, more than one space, before or after the semicolon - it just gets messy - and emails are messy enough already.

