我想使用新的< input type =“email”/>元件.我希望
Java代码在浏览器中实现的服务器上实现相同的验证.
1*( atext / "." ) "@" ldh-str *( "." ldh-str )
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str> <let-dig-hyp> ::= <let-dig> | "-" <let-dig> ::= <letter> | <digit> <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case <digit> ::= any one of the ten digits 0 through 9
atext = ALPHA / DIGIT / ; Printable US-ASCII "!" / "#" / ; characters not including "$" / "%" / ; specials. Used for atoms. "&" / "'" / "*" / "+" / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" / "~"
这些规则与RFC 5322中的规则不同.
如何在Java中测试地址是否符合这些规则?@H_301_3@
谢谢!@H_301_3@
解决方法
你可以使用正则表达式:
[A-Za-z0-9!#$%&'*+-/=?^_`{|}~]+@[A-Za-z0-9-]+(.[A-Za-z0-9-]+)*