Hey y'all, I got over my brain cramp and thought I'd share with the group in
case it helps anyone trying to do something similar. I was making it way too
complicated. All I needed was:

if($email !~ /\w+@\w+\.\w{2,4}/)
{
 # error stuff here
}


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


-----Original Message-----
From: Scot Robnett [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 09, 2002 3:47 PM
To: [EMAIL PROTECTED]
Subject: Regex question


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]


---
Incoming 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

---
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