Email validator regex

Possible Duplicate:
Regexp recognition of email address hard?

Hi,

I would like to implement validator for only local part of the email address.

Any suggestions please welcome.


From the Email address article at wikipedia (Syntax section):

The local-part of the email address may use any of these ASCII characters:

  • Uppercase and lowercase English letters (a–z, A–Z)
  • Digits 0 to 9
  • Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
  • Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively (eg John..Doe@example.com).
  • The syntax is formally defined in RFC 5322 section 3.4.1 and RFC 5321. It is defined by a grammar in which the local part starts like this:

    local-part      =   dot-atom / quoted-string / obs-local-part
    atext           =   ALPHA / DIGIT /    ; Printable US-ASCII
                       "!" / "#" /        ;  characters not including
                       "$" / "%" /        ;  specials.  Used for atoms.
                       "&" / "'" /
                       "*" / "+" /
                       "-" / "/" /
                       "=" / "?" /
                       "^" / "_" /
                       "`" / "{" /
                       "|" / "}" /
                       "~"
    
    atom            =   [CFWS] 1*atext [CFWS]
    
    dot-atom-text   =   1*atext *("." 1*atext)
    
    dot-atom        =   [CFWS] dot-atom-text [CFWS]
    
    ...
    

    Look at the following link. This is the best reference I found:

    http://www.regular-expressions.info/email.html

    链接地址: http://www.djcxy.com/p/92748.html

    上一篇: Sql脚本来查找无效的电子邮件地址

    下一篇: 电子邮件验证器正则表达式