RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Email address (RFC 2821 mailbox)
Expression
^\s*(([/-9!#-'*+=?A-~-]+(?:\.[/-9!#-'*+=?A-~-]+)*|"(?:[^"\r\n\\]|\\.)*")@([A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]?(?:\.[A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]?)*|\[(?:[^\[\]\r\n\\]|\\.)*\]))\s*$
Description
This validates against the RFC 2821 (SMTP) syntax unit 'Mailbox' [equiv. to addr-spec - not address - element of RFC 2822] (the one a certain critic keeps linking to validates the RFC822 'address' element which includes support for stuff like "Group:User <address>,User <address>;", obsolete smtp routing syntax like <@host1,@host2:user@host>, etc) There are some differences. This version does not allow line breaks for continuation lines. It also applies the stricter standards of RFC 2821 (SMTP) to the domain portion of the address. Username may be a quoted string (but not "multiple"."quoted"."strings" - RFC 2822's grammar appears to allow this but the SMTP grammar does not). Also only one piece enclosed in [Brackets] (for IP email addresses) is allowed in the domain; that is you can't have user@[1.2.3.4].[5.6.7.8] as implied by the RFC2822 but not SMTP. Whitespace is only allowed in quoted strings. It is silently ignored at the beginning or end. Capture group 1 is the email address, group 2 is the username, group 3 is the domain.
Matches
[email protected]|[email protected]|"user name"@example.com|user@[192.0.2.4]
Non-Matches
Author Rating: Not yet rated. Jordan
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials