Re: Test not working so well
[email protected] ("Kevin Pye")
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 11 Dec 2023, at 07:31, ToddAndMargo via perl6-users wrote:
> [0] > my Str $x="abc3defg"; if $x.match( / ^ <[0..9]> ** 8 $ / ) { print
> "True\n"; } else { print "False\n" };
> False
>
> "3" is in the string. Why False?
Because you asked for a match with a string consisting entirely of exactly 8 digits.
> my Str $x="abc3defg"; if $x.match( / ^ <[a..h]> ** 8 $ / ) { print
> "True\n"; } else { print "False\n" };
> False
>
> a and b and c and d and e and f and g are also in the string.
> Why the false?
Because the string doesn't exist of exactly eight letters in the range a..h. I.e. there's a 3 in there which isn't a letter in the range a..h.