[英]Regular expression to find particular email addressses
I have a list of following email addresses, 我有以下电子邮件地址的列表,
test1@khm.com,
test2@khm.com,
test3@yahoo.com
test4@gmail.com
new1@gmail.com
How can I validate these email addresses using following email address 如何使用以下电子邮件地址验证这些电子邮件地址
test.*@khm.com
Here I need to get the o/p as 在这里我需要将o / p作为
test1@khm.com,
test2@khm.com
Seems like you want something like this, 好像您想要这样的东西,
^test[^@\\s]*@dhm\\.com$
[^@]*
Matches any character but not of @
zero or more times. [^@]*
匹配任何字符,但不匹配@
零次或多次。
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"));
Output: 输出:
true
true
false
false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.