C
codefire
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 (e-mail address removed), which is not valid. Here's
my attempt, neither of my regexps work quite how I want:
This gives:
(e-mail address removed)
(e-mail address removed)
(e-mail address removed) <-- shouldn't be here
(e-mail address removed)
Nearly there but no cigar
I can't see the wood for the trees now Can anyone suggest a fix
please?
Thanks,
Tony
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 (e-mail address removed), 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'\w+\.?\w+@[^@\s]+\.\w+')
#r = re.compile(r'[a-z\-\.]+@[a-z\-\.]+')
addys = set()
for a in r.findall(s):
addys.add(a)
for a in sorted(addys):
print a
This gives:
(e-mail address removed)
(e-mail address removed)
(e-mail address removed) <-- shouldn't be here
(e-mail address removed)
Nearly there but no cigar
I can't see the wood for the trees now Can anyone suggest a fix
please?
Thanks,
Tony