我需要一个正则表达式来验证逗号分隔的电子邮件

发布于 2025-02-11 05:40:25 字数 635 浏览 1 评论 0原文

我遵循实体框架代码的第一种方法。 我的一个模型中有关注的财产。 我想通过此正则表达式验证逗号分隔的电子邮件。 但这不正常。 例如:

您可以看到它在此处正确验证

。 //i.sstatic.net/cvbhk.png“ alt =”在此处输入图像描述”> 它在这里不起作用

[RegularExpression(@"^(\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+)$",ErrorMessage = "Invalid Email")]
[DisplayName("Participant List")]
public string ParticipantList { get; set; }

,但我想知道, 任何人都知道有效的正则表达式。我非常感谢。

谢谢。

I am following Entity framework code first approach.
I have following property in one of my models.
I want to validate comma separated emails by this regular expression.
But it is not working fine.
Ex:

enter image description here
As you can see it is validating here correctly.

enter image description here
But it doesn't work in here

[RegularExpression(@"^(\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+)
quot;,ErrorMessage = "Invalid Email")]
[DisplayName("Participant List")]
public string ParticipantList { get; set; }

Anyone know any regular expression that works properly, i would like to know. I am highly appreciate it.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风启觞 2025-02-18 05:40:25

要在文本框中验证多个电子邮件,您可以使用以下正则表达式

^(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*,\s*|\s*$))*$

For validating multiple emails in TextBox, you can use following regular expression

^(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*,\s*|\s*$))*$
眼眸印温柔 2025-02-18 05:40:25

在REGEX匹配之后,如果发现任何电子邮件(如果昏迷也匹配后发出无效的电子邮件)

((\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+),?)+

https:https:// regex101。 com/r/gzn1ny/1


这个与有效的电子邮件匹配的昏迷(如果任何电子邮件无效,则不匹配)

^((\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+),?)+$

https://regex101.com/r/oz7gkd/1

following regex matched if any email found (if an invalid email come after coma matched too)

((\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+),?)+

https://regex101.com/r/GZN1nY/1


this one matched to valid email separated by coma(not matched if any email is invalid)

^((\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?,)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+),?)+$

https://regex101.com/r/Oz7GkD/1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文