Skip to content

Commit f06f384

Browse files
committed
Document Str's .starts-with and .ends-with ignorecase/ignoremark
Refs #3229
1 parent 370d238 commit f06f384

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

doc/Type/Str.pod6

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,22 +627,54 @@ Examples:
627627
628628
=head2 method starts-with
629629
630-
multi method starts-with(Str:D: Str(Cool) $needle --> Bool:D)
630+
multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase), :m(:$ignoremark) --> Bool:D)
631631
632632
Returns C<True> if the invocant is identical to or starts with C<$needle>.
633633
634634
say "Hello, World".starts-with("Hello"); # OUTPUT: «True␤»
635635
say "https://raku.org/".starts-with('ftp'); # OUTPUT: «False␤»
636636
637+
Since Rakudo version 2020.02, if the optional named parameter
638+
C<:ignorecase>, or C<:i>, is specified, the comparison of the invocant
639+
and C<$needle> ignores the distinction between upper case, lower case
640+
and title case letters.
641+
642+
say "Hello, World".starts-with("hello"); # OUTPUT: «False␤»
643+
say "Hello, World".starts-with("hello", :ignorecase); # OUTPUT: «True␤»
644+
645+
Since Rakudo 2020.02, if the optional named parameter C<:ignoremark>,
646+
or C<:m>, is specified, the comparison of the invocant and C<$needle>
647+
only considers base characters, and ignores additional marks such as
648+
combining accents.
649+
650+
say "abc".starts-with("ä"); # OUTPUT: «False␤»
651+
say "abc".starts-with("ä", :ignoremark); # OUTPUT: «True␤»
652+
637653
=head2 method ends-with
638654
639-
multi method ends-with(Str:D: Str(Cool) $needle --> Bool:D)
655+
multi method ends-with(Str:D: Str(Cool) $needle, :i(:$ignorecase), :m(:$ignoremark) --> Bool:D)
640656
641657
Returns C<True> if the invocant is identical to or ends with C<$needle>.
642658
643659
say "Hello, World".ends-with('Hello'); # OUTPUT: «False␤»
644660
say "Hello, World".ends-with('ld'); # OUTPUT: «True␤»
645661
662+
Since Rakudo version 2020.02, if the optional named parameter
663+
C<:ignorecase>, or C<:i>, is specified, the comparison of the invocant
664+
and C<$needle> ignores the distinction between upper case, lower case
665+
and title case letters.
666+
667+
say "Hello, World".ends-with("world"); # OUTPUT: «False␤»
668+
say "Hello, World".ends-with("world", :ignorecase); # OUTPUT: «True␤»
669+
670+
Since Rakudo 2020.02, if the optional named parameter C<:ignoremark>,
671+
or C<:m>, is specified, the comparison of the invocant and C<$needle>
672+
only considers base characters, and ignores additional marks such as
673+
combining accents.
674+
675+
say "abc".ends-with("ç"); # OUTPUT: «False␤»
676+
say "abc".ends-with("ç", :ignoremark); # OUTPUT: «True␤»
677+
646678
=head2 method subst
647679
648680
multi method subst(Str:D: $matcher, $replacement = "", *%options)

0 commit comments

Comments
 (0)