Jdavis wrote: > > hello, 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}/) [1-6]{1} is a more verbose way of saying [1-6]. {1} is implied with every character literal or character class. You COULD write /string [1-6]/ as /s{1}t{1}r{1}i{1}n{1}g{1} {1}[1-6]{1}/ but why would you want to? > this returns true. I want it to only match > a single digit ranging 1-6, You need to learn about anchors. The beginning of line anchor - ^, the end of line anchor - $, the beginning of string anchor - \A, and the end of string anchors - \z and \Z > I thought > the {1} would specifiy to match one time only?? > could someone tell me what im doing wrong :) ? It does match one time only but because the regex is not anchored it will match one character anywhere in the string. If you anchor the regex to the beginning of the line AND to the end of the line then there is no way that the string can contain more characters then your regex specifies. my $choice = 11 if ( $choice =~ /^[1-6]$/ ) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]