如何编写正则表达式来匹配免费电子邮件帐户?

发布于 2024-08-22 09:39:24 字数 148 浏览 3 评论 0原文

我正在尝试编写一个正则表达式来检查电子邮件表单字段是否包含免费电子邮件地址,但没有成功。

本质上,我需要检查电子邮件在电子邮件字段中是否包含: hotmailyahoogmail 等。

I'm trying to write a regular expression that checks if an email form field contains a free email address, with no luck.

Essentially I need to check if the email contains: hotmail, yahoo, gmail etc in the email field.

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

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

发布评论

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

评论(3

葬花如无物 2024-08-29 09:39:24
/\@(hotmail|yahoo|gmail)\.com/
/\@(hotmail|yahoo|gmail)\.com/
左耳近心 2024-08-29 09:39:24

你尝试过大分离吗?

yahoo\.com|googlemail\.com|blah\.net

优点:易于构建、易于阅读、明确。

缺点:可能不是最有效的机制。

Have you tried a big ol' disjunction?

i.e.

yahoo\.com|googlemail\.com|blah\.net

Pros: Easy to build, easy to read, explicit.

Cons: Maybe not the most efficient mechanism.

红墙和绿瓦 2024-08-29 09:39:24

正则表达式就像:

[a-zA-Z0-9_\.+]+@(gmail|yahoo|hotmail)(\.[a-z]{2,3}){1,2}

您可以添加您想要的所有其他域...
对你有帮助吗?

regex would be sth like:

[a-zA-Z0-9_\.+]+@(gmail|yahoo|hotmail)(\.[a-z]{2,3}){1,2}

you can add all the other domains you want...
does it help you?

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