1

Guys is there any standard pattern to determine if an entered string is valid for mailbox? I mean when you want to register an email you can test several things like an email address can't start with a number or dash or underline, spaces and special characters are not allowed, dash is allowed at end of string and etc. Here are several strings which are not allowed, to give you idea:

-mymailbox , mymailbox- , 1mymailbox , my..mailbox , my--mailbox , my-.mailbox , 2321312 , 

In fact there are some email providers which allow even special characters. But I was wondering is there any standard pattern for this?

4

1 回答 1

2

There are a ton of rules which describe if an address conforms to the standard. And there are almost always edge cases which will break the standard.

I use this expression, it's not perfect as there are some edge cases which will slip by but those are easy enough to test by simply sending the test email:

^[_a-z0-9-]+(?:\.[_a-z0-9-]+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)*(?:\.[a-z]{2,4})$

enter image description here

The following regex contains all rules which apply to an email address per the standard. Providing your regex engine handles named back references that regex will work and you can uncomment the commented line.

(?(DEFINE)
    (?<addr_spec> (?&local_part) @ (?&domain) )
    (?<local_part> (?&dot_atom) | (?&quoted_string) | (?&obs_local_part) )
    (?<domain> (?&dot_atom) | (?&domain_literal) | (?&obs_domain) )
    (?<domain_literal> (?&CFWS)? \[ (?: (?&FWS)? (?&dtext) )* (?&FWS)? \] (?&CFWS)? )
    (?<dtext> [\x21-\x5a] | [\x5e-\x7e] | (?&obs_dtext) )
    (?<quoted_pair> \\ (?: (?&VCHAR) | (?&WSP) ) | (?&obs_qp) )
    (?<dot_atom> (?&CFWS)? (?&dot_atom_text) (?&CFWS)? )
    (?<dot_atom_text> (?&atext) (?: \. (?&atext) )* )
    (?<atext> [a-zA-Z0-9!#$%&''*+/=?^_`{|}~-]+ )
    (?<atom> (?&CFWS)? (?&atext) (?&CFWS)? )
    (?<word> (?&atom) | (?&quoted_string) )
    (?<quoted_string> (?&CFWS)? "" (?: (?&FWS)? (?&qcontent) )* (?&FWS)? "" (?&CFWS)? )
    (?<qcontent> (?&qtext) | (?&quoted_pair) )
    (?<qtext> \x21 | [\x23-\x5b] | [\x5d-\x7e] | (?&obs_qtext) )

    # comments and whitespace
    (?<FWS> (?: (?&WSP)* \r\n )? (?&WSP)+ | (?&obs_FWS) )
    (?<CFWS> (?: (?&FWS)? (?&comment) )+ (?&FWS)? | (?&FWS) )
    (?<comment> \( (?: (?&FWS)? (?&ccontent) )* (?&FWS)? \) )
 #   (?<ccontent> (?&ctext) | (?&quoted_pair) | (?&comment) )
    (?<ccontent> (?&ctext) | (?&quoted_pair) )
    (?<ctext> [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?&obs_ctext) )

    # obsolete tokens
    (?<obs_domain> (?&atom) (?: \. (?&atom) )* )
    (?<obs_local_part> (?&word) (?: \. (?&word) )* )
    (?<obs_dtext> (?&obs_NO_WS_CTL) | (?&quoted_pair) )
    (?<obs_qp> \\ (?: \x00 | (?&obs_NO_WS_CTL) | \n | \r ) )
    (?<obs_FWS> (?&WSP)+ (?: \r\n (?&WSP)+ )* )
    (?<obs_ctext> (?&obs_NO_WS_CTL) )
    (?<obs_qtext> (?&obs_NO_WS_CTL) )
    (?<obs_NO_WS_CTL> [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f )

    # character class definitions
    (?<VCHAR> [\x21-\x7E] )
    (?<WSP> [ \t] )
)
((?&addr_spec))

With a single line commented out to prevent infinite recursion, this expression can be converted into something most any regex engines can handle (be sure to use the x option):

((?: (?: (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: \. (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) )* ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? "" (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: \x21 | [\x23-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? "" (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? "" (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: \x21 | [\x23-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? "" (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) ) (?: \. (?: (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? "" (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: \x21 | [\x23-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? "" (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) ) )* ) ) @ (?: (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: \. (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) )* ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? \[ (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: [\x21-\x5a] | [\x5e-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \] (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) | (?: (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) (?: \. (?: (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? (?: [a-zA-Z0-9!#$%&'*+/=?^_{|}~-]+ ) (?: (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: \( (?: (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? (?: (?: [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?: (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ) ) | (?: \\ (?: (?: [\x21-\x7E] ) | (?: [ \t] ) ) | (?: \\ (?: \x00 | (?: [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) | \n | \r ) ) ) ) )* (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? \) ) )+ (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) )? | (?: (?: (?: [ \t] )* \r\n )? (?: [ \t] )+ | (?: (?: [ \t] )+ (?: \r\n (?: [ \t] )+ )* ) ) )? ) )* ) ) ))

于 2013-07-20T14:10:28.223 回答