Course of Raku / Regexes and grammars / Regexes / Matching strings / Exercises / The matched text
Solution: The matched text
Here is a possible solution to the task.
Code
'database' ~~ /base/;
say $/.Str;🦋 You can find the source code in the file matched-text.raku.
Output
baseComments
Every smartmatch stores its result in the special match variable
$/, so there is no need to assign it to a variable of our own.The match object holds the matched text; calling
.Stron$/returns that text as an ordinary string. Printing the match object directly would have shown「base」instead.