Hello, I'm wondering if there's a REPL-specific issue with the following
docs.raku.org code? The code can be found at:
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.

Reply via email to