Skip to content

Commit a77eccf

Browse files
committed
Document Str.substr-eq ignorecase/ignoremark
Refs #3229
1 parent c799e9f commit a77eccf

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

doc/Type/Str.pod6

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ to the index of the last character.
843843
844844
=head2 method substr-eq
845845
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)
848848
849849
Returns C<True> if the C<$test-string> exactly matches the C<String> object,
850850
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:
864864
my $string = "foobar";
865865
say $string.substr-eq("foobar", 0); # OUTPUT: «True␤»
866866
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+
867883
Since this method is inherited from the C<Cool> type, it also works on
868884
integers. Thus the integer C<42> will match the value C<342> starting from
869885
index 1:

xt/code.pws

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ cha
144144
childclass
145145
childname
146146
chocolatey
147+
cliché
147148
clogger
148149
cn
149150
cntrl

0 commit comments

Comments
 (0)