I'm trying to do a simple verification of an e-mail address format. I want
to require:

        - 1 or more alphanumeric characters
        - followed by "@"
        - followed by 1 or more alphanumerics
        - followed by a dot
        - followed by 2-4 alphanumerics.
          (for example, .tv, .com, .info)

If the string doesn't fit these requirements, then I send them back to the
form to re-enter the address. The problem is that using the code below, the
program complains even when the address *is* formatted properly. Any ideas
how I could reformat the expression better?

##########################################################

if(($email !=~ /\w+[@]\w+\.\w{2}/) or ($email !=~ /\w+[@]\w+\.\w{3}/)
or ($email !=~ /\w+[@]\w+\.\w{4}/))
{
 print "Improperly formatted e-mail address! Please use your browser\'s back
";
 print "button and make sure the e-mail address is entered correctly. ";
}

##########################################################



-----
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
http://www.insiteful.tv

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to