File tree Expand file tree Collapse file tree 1 file changed +1
-6
lines changed Expand file tree Collapse file tree 1 file changed +1
-6
lines changed Original file line number Diff line number Diff line change @@ -1007,7 +1007,7 @@ for repeated operations:
1007
1007
1008
1008
my $string = "A character in the 'Flintstones' is: barney";
1009
1009
$string ~~ /(barney)/;
1010
- my $ref := substr-rw($string, $0.from, $0.to);
1010
+ my $ref := substr-rw($string, $0.from, $0.to-$0.from );
1011
1011
$string.say;
1012
1012
# OUTPUT: «A character in the 'Flintstones' is: barney»
1013
1013
$ref = "fred";
@@ -1017,11 +1017,6 @@ for repeated operations:
1017
1017
$string.say;
1018
1018
# OUTPUT: «A character in the 'Flintstones' is: wilma»
1019
1019
1020
- Notice that the start position and length of string to replace has been
1021
- specified via the C < .from > and C < .to > methods on the C < Match > object, C < $0 > .
1022
- It is thus not necessary to count characters in order to replace a
1023
- substring, hence making the code more flexible.
1024
-
1025
1020
= head2 routine samemark
1026
1021
1027
1022
multi sub samemark(Str:D $string, Str:D $pattern --> Str:D)
You can’t perform that action at this time.
0 commit comments