mail field using regex
I need to check if a string (local part of email address) has nothing except:
How do I do it using Java regex
?
Example: a_1_b.c
and a_b_1
, should be okay ,but 1.a_b.2
and 1_a*3
should be discarded.
If you want to verify email correctness you might want to just rely on the JavaMail API to do it for you. Then you don't need to worry about encoding the details of the RFC 822 specification into a regex. Not to mention if you're dealing with email addresses you likely want an easy way to send them, and the library has that too. You could verify that an email address is valid with simply:
try {
new InternetAddress(email).getAddress();
} catch (AddressException e) {
// it's not valid
}
你应该在这里找到更多的信息。
我想,正则表达式[w]*.[w]+|[w]+
应该可以工作。
上一篇: 在oracle varchar列值中给定符号后面的字符数
下一篇: 邮件字段使用正则表达式