4

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.

Community
  • 1
  • 1
Isabel Jinson
  • 8,541
  • 16
  • 59
  • 75
  • 3
    possible duplicate of [Regexp recognition of email address hard?](http://stackoverflow.com/questions/156430/regexp-recognition-of-email-address-hard) Although this question specifically states the *local part* is of interest, the answer will most likely be found in any other email+regex question that has already been asked. – Aron Rotteveel Feb 10 '11 at 09:48
  • @Aron Rotteveel. @Thomman only wants to validate the *local part* of the email address – Raghuram Feb 10 '11 at 09:50
  • 1
    @Raghuram: which is *exactly* what I explained in the comment above. – Aron Rotteveel Feb 10 '11 at 09:52

2 Answers2

1

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 (e.g. 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]

...
Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
1

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

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

AlexR
  • 114,158
  • 16
  • 130
  • 208