🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
tbrowder__ m: my $a = "acerbic"; say so $a ~~ /^ a|ac|ace/ 20:51
camelia True
tbrowder__ is there an easier way to match any partial leading chars of a target string? 20:53
Voldenet m: for "a", "ab", "ac", "ace", "acer" { say $_ eq "acerbic".substr(0, $_.chars) }' 21:02
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> ay $_ eq "acerbic".substr(0, $_.chars) }⏏'
Voldenet m: for "a", "ab", "ac", "ace", "acer" { say $_ eq "acerbic".substr(0, $_.chars) }
camelia True
False
True
True
True
21:03
Voldenet something like that perhaps
btw, the above regex can be shortened to /^a/ 21:06
so it might be not what you actually wanted 21:07
clarkema evening 21:35
tbrowder__ correct, i want it for matching option args in a raku prog. allow one or more of the correct order of the leading chars of the option. 21:55
but i'll bet lizmat has a shorter method... 21:56
nemokosch so the longest valid prefix 21:59
tbrowder__ it's a pain to manually chop the word into abbreviation. ah, maybe my Abbreviation module can help!
Abbreviations 22:00
yes! 22:03
m: use Abbreviations 22:04
camelia ===SORRY!=== Error while compiling <tmp>
Could not find Abbreviations in:
/home/camelia/.raku
/home/camelia/rakudo-m-inst-1/share/perl6/site
/home/camelia/rakudo-m-inst-1/share/perl6/vendor
/home/camelia/rakudo-m-inst-1…
tbrowder__ bummer