@@ -627,22 +627,54 @@ Examples:
627
627
628
628
= head2 method starts-with
629
629
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)
631
631
632
632
Returns C < True > if the invocant is identical to or starts with C < $needle > .
633
633
634
634
say "Hello, World".starts-with("Hello"); # OUTPUT: «True»
635
635
say "https://raku.org/".starts-with('ftp'); # OUTPUT: «False»
636
636
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
+
637
653
= head2 method ends-with
638
654
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)
640
656
641
657
Returns C < True > if the invocant is identical to or ends with C < $needle > .
642
658
643
659
say "Hello, World".ends-with('Hello'); # OUTPUT: «False»
644
660
say "Hello, World".ends-with('ld'); # OUTPUT: «True»
645
661
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
+
646
678
= head2 method subst
647
679
648
680
multi method subst(Str:D: $matcher, $replacement = "", *%options)
0 commit comments