On 12/10/23 19:52, Kevin Pye wrote:


On Mon, 11 Dec 2023, at 09:24, ToddAndMargo via perl6-users wrote:
On 12/10/23 14:16, Kevin Pye wrote:

Because you asked for a match with a string consisting entirely of exactly 8 
digits.

I am not following.  :'(

^    beginning of string

<[0..9]> a digit

What do you mean "a digit".  This is not the index of the string?

I though I was testing for the characters "0" (char 48)
through "9" (char 57), not the numbers 0 through 9.


** 8 repeated exactly eight times

% end of string

What does the $ mean

so /^ <[0..9]> ** 8 $/ means exactly eight digits in the string, and nothing 
else. You have eight characters, but seven of them aren't digits, so the match fails.

Similarly in the second case.

Slowly getting there.



The Perl5 guys had a way of explaining functions that
really worked for me.  You are using the technique, so I
will give it a try and you tell me what I am doing wrong:

my Str $x="abc3defg";
if $x.match( / ^ <[0..9]> ** 8 $ / ) {
   print "True\n"; } else { print "False\n" };
False


$x is the string to test

`.match()` is the test command (method) applied to $x

the beginning and ending `/` are the constraints of the test

`^` means to start testing at the beginning of $x

`$` means to stop testing at the end of $x

`<[0..9]>` are the range of alpha numeric characters
(not numbers) to test for in  $x

`** 8` means to the test each index of $x advancing one at a
time up to  eight times.  Each index of $x is tested for
the existence of <[0..9]>.  The `8` is not the number of
characters in $x.




I am sure I got half of it wrong.

Thank you for the help!
-T




--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to