是否有HTML5输入电子邮件验证的Java实现?

前端之家收集整理的这篇文章主要介绍了是否有HTML5输入电子邮件验证的Java实现?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用新的< input type =“email”/>元件.我希望 Java代码在浏览器中实现的服务器上实现相同的验证.

ABNFABNF作为:

1*( atext / "." ) "@" ldh-str *( "." ldh-str )

where

<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

and

atext           =   ALPHA / DIGIT /    ; Printable US-ASCII
                       "!" / "#" /        ;  characters not including
                       "$" / "%" /        ;  specials.  Used for atoms.
                       "&" / "'" /
                       "*" / "+" /
                       "-" / "/" /
                       "=" / "?" /
                       "^" / "_" /
                       "`" / "{" /
                       "|" / "}" /
                       "~"

这些规则与RFC 5322中的规则不同.
如何在Java中测试地址是否符合这些规则?

谢谢!

解决方法

你可以使用正则表达式:
[A-Za-z0-9!#$%&'*+-/=?^_`{|}~]+@[A-Za-z0-9-]+(.[A-Za-z0-9-]+)*

猜你在找的HTML5相关文章