OT: regex to find email
Josh Close
narshe at gmail.com
Tue Sep 21 11:41:10 EDT 2004
More information about the Python-list mailing list
Tue Sep 21 11:41:10 EDT 2004
- Previous message (by thread): OT: regex to find email
- Next message (by thread): OT: regex to find email
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 21 Sep 2004 20:45:29 +0530, Steve <lonetwin at gmail.com> wrote: > Hi Josh, > > I've been trying to find a good regex to parse emails, but haven't > > found any to my liking. I basically need to have > > I'm assuming you meant 'good regex to parse email ids'. I knew someone > would want this someday :). Here goes: > import re > r = re.compile (r"""(?P<name>["(].+[")]\s)? # The name preceding > the id, if any > (?P<mailid>[<\w]+[-\w.<+]+@(\w+\.)+[\w>]+) # The actual id > (?P<trailing>\s["(].+[")])? # The > trailing name if any > """, re.VERBOSE) > re.search(r, '-sdf at sdf.cas').group('mailid') > > HTH > Steve > This doesn't exactly work because if an email is -name at domain.tld then it picks it up as name at domain.tld, when it should be an invalid id. -Josh
- Previous message (by thread): OT: regex to find email
- Next message (by thread): OT: regex to find email
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list