Hi,
I am trying to get a regexp to validate email addresses but can't get
it quite right. The problem is I can't quite find the regexp to deal
with ignoring the case [EMAIL PROTECTED], which is not valid. Here's
my attempt, neither of my regexps work quite how I want:
[code]
import os
import re
s = 'Hi [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] @@not
[EMAIL PROTECTED] partridge in a pear tree'
r = re.compile(r'[EMAIL PROTECTED]@\s]+\.\w+')
#r = re.compile(r'[EMAIL PROTECTED]')
addys = set()
for a in r.findall(s):
addys.add(a)
for a in sorted(addys):
print a
[/code]
This gives:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED] <-- shouldn't be here :(
[EMAIL PROTECTED]
Nearly there but no cigar :)
I can't see the wood for the trees now :) Can anyone suggest a fix
please?
Thanks,
Tony
--
http://mail.python.org/mailman/listinfo/python-list