LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > CGI/Perl/Python > Regular expression - range of numbers

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-13-2007, 07:25 AM
rjulich rjulich is offline
New Member
 
Join Date: Feb 2007
Posts: 4
Default Regular expression - range of numbers

I am writing a perl program that takes the month of the year as input. I want to check the input and make sure it is a digital between 1 and 12 and if it not, keep looping until it is. Also, is it possible to check to see is the input is exactly between 1 and 12 (i.e. will accept 12 but not accept 12x)?

I have tried:

while($month !~ /^(1|2|3|4|5|6|7|8|9|10|11|12)/)
{
print "\n Enter month: ";
chomp($month = <STDIN>);
}

But that isn't working. Thanks in advance for the help.

Ray
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:00 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.