Search code examples
c#asp.netregexemail-validation

blank space in multiple email addresses after ","


I am using RegularExpressionValidator to validate multiple email addresses seprated by a comma ","

My below expression works fine for this requirment:

"((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*"

Requirment is this expression should be able to handle space after comma in email addresses.

For example my current expression work file for [email protected],[email protected] but what it do not do is [email protected], [email protected]

I understand there can be many solutions but in my snario best is to enhance this expression.

Please guide me


Solution

  • Here is my suggestion:

    ((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([, ])*)*
    

    That will accept blanks between the e-mail addresses