I need to validate email addresses which can be single or several comma-separated ones.
Before I was using in a regular expression validator an expression like:
string exp = @"((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*";
and it was validating multiple or one single email address.
But same expression is not valdiating in C#? It says valid to invalid addresses as well.
Please correct me or suggest me an expression to validate email addresse(s).
Please give more details. Which addresses are matched as valid, but should be invalid? How do you call the regex (your c# code)?
A point I see is that you are missing anchors.
^matches the start of the string$matches the end of the stringIf you don’t use them your pattern will match as soon as it found a valid sub string.