Course of Raku / Regexes and grammars / Regexes / Substitution and replacement / The substitution operator
Quiz — The s/// operator
What does the following program print?
my $s = 'one two two';
$s ~~ s/two/three/;
say $s;| 1 | one three two |
| 0 | one three three |
| 0 | one two two |
| 0 | three two two |
Without the :g adverb, s/// replaces only
the first match. So just the first two
becomes three, giving one three two. With
s:g/// both occurrences would change.