gpt4 book ai didi

java - 用于查找特定电子邮件地址的正则表达式

转载 作者:行者123 更新时间:2023-12-01 12:21:03 26 4
gpt4 key购买 nike

我有以下电子邮件地址列表,

test1@khm.com,
test2@khm.com,
test3@yahoo.com
test4@gmail.com
new1@gmail.com

如何使用以下电子邮件地址验证这些电子邮件地址

test.*@khm.com

这里我需要将o/p获取为

test1@khm.com,
test2@khm.com

最佳答案

看起来你想要这样的东西,

^test[^@\\s]*@dhm\\.com$

[^@]* 匹配任何字符但不匹配 @ 零次或多次。

System.out.println("test1@dhm.com".matches("test[^@\\s]*@dhm\\.com"));
System.out.println("test2@dhm.com".matches("test[^@\\s]*@dhm\\.com"));
System.out.println("test4@gmail.com".matches("test[^@\\s]*@dhm\\.com"));
System.out.println("new1@gmail.com".matches("test[^@\\s]*@dhm\\.com"));

输出:

true
true
false
false

关于java - 用于查找特定电子邮件地址的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26655643/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com