regular expression help [port]

Leith Parkin leithp at selector.com
Sun Sep 15 11:27:01 EDT 2002


Here is what i use

import re
def valid(email):
        x = 
re.match("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3
}$", email);        if x == None:
                return 0;
        else:
                return 1;

Sorry about the formatting errors

Leith

On Sun, 15 Sep 2002 09:56:38 GMT
":B nerdy" <thoa0025 at mail.usyd.edu.au> wrote:

> Greetings, this is a regular expression for an email address
> "^[a-z0-9_]+@[a-z0-9\-]{2,}\.[a-z0-9\-\.]{2,}$"
> 
> i wish to valid a variable against this string. would someone be so kind
> to supply a few lines of code to do this?
> 
> cheers
> 
> 


-- 
It is Texas law that when two trains meet each other at a railroad
crossing,
each shall come to a full stop, and neither shall proceed until the other
has gone.



More information about the Python-list mailing list