@@ -843,8 +843,8 @@ to the index of the last character.
843
843
844
844
= head2 method substr-eq
845
845
846
- multi method substr-eq(Str:D: Str(Cool) $test-string, Int(Cool) $from --> Bool)
847
- multi method substr-eq(Cool:D: Str(Cool) $test-string, Int(Cool) $from --> Bool)
846
+ multi method substr-eq(Str:D: Str(Cool) $test-string, Int(Cool) $from, :i(:$ignorecase), :m(:$ignoremark) --> Bool)
847
+ multi method substr-eq(Cool:D: Str(Cool) $test-string, Int(Cool) $from, :i(:$ignorecase), :m(:$ignoremark) --> Bool)
848
848
849
849
Returns C < True > if the C < $test-string > exactly matches the C < String > object,
850
850
starting from the given initial index C < $from > . For example, beginning with
@@ -864,6 +864,22 @@ Naturally, to match the entire string, one merely matches from index 0:
864
864
my $string = "foobar";
865
865
say $string.substr-eq("foobar", 0); # OUTPUT: «True»
866
866
867
+ Since Rakudo version 2020.02, if the optional named parameter
868
+ C < :ignorecase > , or C < :i > , is specified, the comparison of the invocant
869
+ and C < $test-string > ignores the distinction between upper case,
870
+ lower case and title case letters.
871
+
872
+ say "foobar".substr-eq("Bar", 3); # OUTPUT: «False»
873
+ say "foobar".substr-eq("Bar", 3, :ignorecase); # OUTPUT: «True»
874
+
875
+ Since Rakudo version 2020.02, if the optional named parameter
876
+ C < :ignoremark > , or C < :m > , is specified, the comparison of the
877
+ invocant and C < $test-string > only considers base characters, and
878
+ ignores additional marks such as combining accents.
879
+
880
+ say "cliché".substr-eq("che", 3); # OUTPUT: «False»
881
+ say "cliché".substr-eq("che", 3, :ignoremark); # OUTPUT: «True»
882
+
867
883
Since this method is inherited from the C < Cool > type, it also works on
868
884
integers. Thus the integer C < 42 > will match the value C < 342 > starting from
869
885
index 1:
0 commit comments