JavaPro

          On the Java Road
          隨筆 - 26, 文章 - 0, 評論 - 63, 引用 - 0
          數據加載中……

          Email驗證的正則表達式

                這個Email驗證的正則表達式基本符合RFC3521規范,缺少ipv6部分的驗證。

                  Mail=("[\\x20-\\x21\\x23-\\x5B\\x5D-\\x7E]*"|"(\\\\[\\x20-\\x7E])*"|^[-!#$%&\'*+/0-9=?A-Z\\^_`a-z{|}~]+(.[-!#$%&\'*+/0-9=?A-Z\\^_`a-z{|}~]+)*)@([a-zA-Z0-9]+([\\-\\da-zA-Z]*[a-zA-Z0-9]+)*(\\.[a-zA-Z\\d]+([\\-\\da-zA-Z]*[a-zA-Z0-9]+)*)*|[\\[]((1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9]))[\\]]|((1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])\\.(1[0-9][0-9]|25[0-5]|2[0-4][0-9]|0[0-9][0-9]|00[0-9]|[0-9][0-9]|[0-9])))

                RFC3521中的相關定義:
                        Domain         = sub-domain *("." sub-domain)
                        sub-domain     = Let-dig [Ldh-str]

             Let-dig        = ALPHA / DIGIT

             Ldh-str        = *( ALPHA / DIGIT / "-" ) Let-dig

             address-literal  = "[" ( IPv4-address-literal /
                              IPv6-address-literal /
                              General-address-literal ) "]"
                              ; See Section 4.1.3

             Mailbox        = Local-part "@" ( Domain / address-literal )

             Local-part     = Dot-string / Quoted-string
                            ; MAY be case-sensitive


             Dot-string     = Atom *("."  Atom)

             Atom           = 1*atext

             Quoted-string  = DQUOTE *QcontentSMTP DQUOTE

             QcontentSMTP   = qtextSMTP / quoted-pairSMTP

             quoted-pairSMTP  = %d92 %d32-126
                              ; i.e., backslash followed by any ASCII
                              ; graphic (including itself) or SPace

             qtextSMTP      = %d32-33 / %d35-91 / %d93-126
                            ; i.e., within a quoted string, any
                            ; ASCII graphic or space is permitted
                            ; without blackslash-quoting except
                            ; double-quote and the backslash itself.

          posted on 2008-12-19 15:43 Jason Du 閱讀(589) 評論(0)  編輯  收藏 所屬分類: 程序人生

          主站蜘蛛池模板: 顺义区| 蓬莱市| 汝南县| 宜城市| 霍林郭勒市| 都江堰市| 沈丘县| 大埔区| 民丰县| 张家川| 永州市| 巴东县| 民和| 阳山县| 屯留县| 宝丰县| 乳源| 安义县| 郓城县| 特克斯县| 大洼县| 开平市| 宜宾市| 万全县| 清徐县| 铜山县| 吉安市| 烟台市| 金寨县| 玉溪市| 镇安县| 故城县| 高雄市| 葵青区| 城口县| 奉新县| 新乐市| 大埔县| 尚志市| 新竹县| 芒康县|