Re: Test not working so well
[email protected] (ToddAndMargo via perl6-users)
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
On 12/11/23 15:48, William Michels via perl6-users wrote: > > >> On Dec 10, 2023, at 23:22, ToddAndMargo via perl6-users >> <[email protected]> wrote: >> >> On 12/10/23 22:26, William Michels via perl6-users wrote: >> <SNIP> >> Hi Bill, >> Yes it does help. I am slowly getting there. >> >> If I do not know the length of the sting and have to ask >> with .chars, is there a way to use a variable in `** 7` >> >> ** $x.chars or >> my $xlen = $x.chars; `** $xlen` >> >> or some such? Is there a special syntax? >> Also, must the `**7` (does it have a name?) always be the length >> of the string? >> Also, if I do not use ^ and $, what happens? >> >> Yours in confusion, >> -T > > > In the Raku REPL (MoarVM 2023.05): > > [3] > my $x="abc2def"; put $x.match: / ^ <alnum> ** 7 $ /; > abc2def > [3] > my $x="abc2def"; put so $x.match: / ^ <alnum> ** 7 $ /; > True > [3] > my $x="abc2def"; put $x.match: / ^ <alnum> ** {$x.chars} $ /; > abc2def > [3] > my $x="abc2def"; put $x.match: / ^ <alnum> ** {$x.chars + 1} $ /; > Use of Nil in string context > in block <unit> at <unknown file> line 1 > > > [3] > my $x="abc2def"; say $x.match: / ^ <alnum> ** {$x.chars + 1} $ /; > Nil > [3] > my $x="abc2def"; say $x.match: / ^ <alnum> ** {$x.chars} $ /; > 「abc2def」 > alnum => 「a」 > alnum => 「b」 > alnum => 「c」 > alnum => 「2」 > alnum => 「d」 > alnum => 「e」 > alnum => 「f」 > [3] > my $x="abc2def"; say so $x.match: / ^ <alnum> ** {$x.chars} $ /; > True > [3] > my $x="abc2def"; say so $x.match: / ^ <alnum> ** {$x.chars + 1} $ /; > False > [3] > > > HTH, Bill. Is there a list somewhere of all the shortcuts, such as "alnum"? -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computers are like air conditioners. They malfunction when you open windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~