• GilaMonster (8/27/2014)


    sqldriver (8/27/2014)


    GilaMonster (8/27/2014)


    sqldriver (8/27/2014)


    I used to use this. Not perfect by any stretch but got most of the junk out.

    Does it flag this as invalid?

    MyAccount+SSC@Gmail.com

    http://gmailblog.blogspot.com/2008/03/2-hidden-ways-to-get-more-from-your.html

    It does.

    Which is why I point people at that linked blog post on this topic, as what is allowed is much broader than most regex statements allow.

    Yes, my favorite reference is Mail::RFC822::Address: regexp-based address validation

    Which has a sample Perl RegEx for RFC822 validation, NOT including the arbitrarily nested comments allowed by the RFC.

    (?:(?:\r)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t]

    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:

    \r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(

    ?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[

    \t]))*"(?:(?:\r)?[ \t])*))*@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0

    31]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+

    (?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:

    (?:\r)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z

    |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)

    ?[ \t])*)*\<(?:(?:\r)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[

    \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)

    ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t]

    )*))*(?:,@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[

    \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*

    )(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t]

    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*)

    *:(?:(?:\r)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+

    |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r

    )?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:

    \r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t

    ]))*"(?:(?:\r)?[ \t])*))*@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031

    ]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](

    ?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?

    :(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?

    :\r)?[ \t])*))*\>(?:(?:\r)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?

    :(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?

    [ \t]))*"(?:(?:\r)?[ \t])*)*:(?:(?:\r)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\]

    \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|

    \\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>

    @,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"

    (?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*))*@(?:(?:\r)?[ \t]

    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?

    :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[

    \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-

    \031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(

    ?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)*\<(?:(?:\r)?[ \t])*(?:@(?:[^()<>@,;

    :\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([

    ^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\"

    .\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*(?:,@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\]

    \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]

    |\\.)*\](?:(?:\r)?[ \t])*))*)*:(?:(?:\r)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0

    00-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[^()<>@,

    ;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?

    :[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*))*@(?:(?:\r)?[ \t])*

    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".

    \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t])*(?:[

    ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]

    ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*\>(?:(?:\r)?[ \t])*)(?:,\s*(

    ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)(?:\.(?:(

    ?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[

    \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t

    ])*))*@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t

    ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?

    :\.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|

    \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*|(?:

    [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)*\<(?:(?:\r)

    ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["

    ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)

    ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>

    @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*(?:,@(?:(?:\r)?[

    \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,

    ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:\.(?:(?:\r)?[ \t]

    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*)*:(?:(?:\r)?[ \t])*)?

    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\["()<>@,;:\\".

    \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])*)(?:\.(?:(?:

    \r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z|(?=[\[

    "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r)?[ \t]))*"(?:(?:\r)?[ \t])

    *))*@(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])

    +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*)(?:.(?:(?:\r)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r)?[ \t])+|\Z

    |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r)?[ \t])*))*\>(?:(

    ?:\r)?[ \t])*))*)?;\s*)

    P.S. I tried code="plain" but the sad faces, well, they're not stopped by that.