On 2/4/21 10:58 AM, William Michels via perl6-users wrote:
Hello, I'm wondering if there's a REPL-specific issue with the following
docs.raku.org <http://docs.raku.org> code? The code can be found at:
https://docs.raku.org/language/regexes#Regex_interpolation
<https://docs.raku.org/language/regexes#Regex_interpolation>
> my $string = 'Is this a regex or a string: 123\w+False$pattern1 ?';
Is this a regex or a string: 123\w+False$pattern1 ?
> my $regex = /\w+/;
/\w+/
> say $string.match: / $regex /; # EXPECTED OUTPUT: «「Is」»
Regex object coerced to string (please use .gist or .raku to do that)
in any metachar at
/Users/homedir/rakudo/rakudo-2020.10/install/share/nqp/lib/NQPP6QRegex.moarvm
line 1
in any termseq at
/Users/homedir/rakudo/rakudo-2020.10/install/share/nqp/lib/NQPP6QRegex.moarvm
line 1
in any quote:sym</ /> at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
in any quote at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
in any value:sym<quote> at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
in any value at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
in any term:sym<value> at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
in any term at
/Users/homedir/rakudo/rakudo-2020.10/install/share/perl6/lib/Perl6/Grammar.moarvm
line 1
「」
> $*VM
moar (2020.10)
>
I can get the .match code to work in the REPL by removing the forward
slashes and/or using a smartmatch operator:
> say $string ~~ $regex ;
「Is」
> say $string.match: $regex ;
「Is」
> say $string.match(:g, $regex) ;
(「Is」 「this」 「a」 「regex」 「or」 「a」 「string」 「123」 「w」 「False」 「pattern1」)
The problematic REPL line seems to work just fine in a standalone
script, so any feedback appreciated.
Thanks, Bill.
W. Michels, Ph.D.
Hi Bill,
Not what you asked, but when does that stop me!
I do adobe REPL, but is has so many bugs in it
that it fails me 60% of the time.
I switch to one lines in that case:
$ alias p6
alias p6='perl6 -e'
$ p6 'my $string = "Is this a regex or a string: 123\\w+False\$pattern1
?"; my $regex = /\w+/; say $string.match: / $regex /;'
「Is」
Note the double backslash I added: 123\\w
Hope this is somewhat helpful,
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~