CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
how 2 distinquish.

 



v0dka
Novice

Oct 1, 2002, 7:46 AM

Post #1 of 4 (3479 views)
how 2 distinquish. Can't Post

regular Expessions validation. Edit | Delete | Quote | Reply | Private Reply
I need to be a bit of a cheeky badger!

My program will take 2 types of user names. These will be in the format of 2 letters and 2 digits e.g zx12, OR 2 letters and 3 digits eg. as123. I need my program to distinguish between the 2.

if ($username =~ 2 letters and 2 digits) {

do this

}else if ($username =~ 2 letters and 3 digits) {

do this

}

Any help will be much appreciated cheers!!



Paul
Enthusiast

Oct 1, 2002, 8:41 AM

Post #2 of 4 (3478 views)
Re: [v0dka] how 2 distinquish. [In reply to] Can't Post


Code
if ($username =~ /^[a-z]{2}\d{2,3}$/i) {



uri
Thaumaturge

Oct 1, 2002, 11:19 PM

Post #3 of 4 (3473 views)
Re: [RedRum] how 2 distinquish. [In reply to] Can't Post


In Reply To

Code
if ($username =~ /^[a-z]{2}\d{2,3}$/i) {



that doesn't do what the OP asked. it matches either name format but he wanted to distinguish between a 2 or 3 digit ending part. that should be an easy change for you to make so i won't do it myself.

uri


Bode
Novice

Oct 2, 2002, 3:33 AM

Post #4 of 4 (3470 views)
Re: [v0dka] how 2 distinquish. [In reply to] Can't Post

Wink Cheers people!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives