a more precise re for email addys

skip at pobox.com skip at pobox.com
Wed Jan 18 15:16:46 EST 2006


    rbt> re.compile('([\w\.\-]+@[\w\.\-]+)')
    rbt> re.compile(r'[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}')
    rbt> re.compile('(\S+)@(\S+)')

    rbt> All of these will find email addys, but they also find other
    rbt> things.

I think the only way to decide if your regular expression does what you want
is to provide a set of strings it must accept and another set which it must
reject.  Supply those two sets and I'm sure any number of people here can
come up with a regular express that distinguishes the two sets.

Skip



More information about the Python-list mailing list