如何使用正则表达式匹配特定域中的所有电子邮件地址? [英] How to match all email addresses at a specific domain using regex?

查看:21
本文介绍了如何使用正则表达式匹配特定域中的所有电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助来查找仅匹配特定域的电子邮件地址的正则表达式

I need help on finding a regex expression that will match email addresses of only a specific domain

在任何.*@testdomain.com

以及除 .*@testdomain.com 之外的任何其他内容

And also the opposite any thing other than .*@testdomain.com

推荐答案

Ay

我提出一个非常简单的表达方式:

I propose an expression very simple:

^[A-Za-z0-9._%+-]+@testdomain.com$

对于否定检查:

^[A-Za-z0-9._%+-]+@(?!testdomain.com)[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$

希望对你有用

这篇关于如何使用正则表达式匹配特定域中的所有电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆