jdavis wrote:
hello,
 while trying to get a grasp on regex
i found this nice little tutorial.
http://www.steve.gb.com/perl/lesson06.html

so i tried this..

$choice = 11
if($choice =~ /[1-6]{1}/)

this returns true. I want it to only match
a single digit ranging 1-6  , I thought
the {1} would specifiy to match one time only??
could someone tell me what im doing wrong :) ?


The {1} does tell it to match one time only, match any character 1-6 one time only, but not match only 1 character from 1-6 :-)..., so it matches the first '1' in the string and that is success.


How about,

if ($choice =~ /^[1-6]$/) {
}

http://danconia.org


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



Reply via email to