How to match a comma separated list of emails with regex?

前端 未结 13 1371
一整个雨季
一整个雨季 2020-12-15 07:29

Trying to validate a comma-separated email list in the textbox with asp:RegularExpressionValidator, see below:



        
13条回答
  •  被撕碎了的回忆
    2020-12-15 07:56

    Try this:

    ^([\w+-.%]+@[\w-.]+\.[A-Za-z]{2,4},?)+$
    

    Adding the + after the parentheses means that the preceding group can be present 1 or more times.

    Adding the ^ and $ means that anything between the start of the string and the start of the match (or the end of the match and the end of the string) causes the validation to fail.

提交回复
热议问题