Documentation for method starts-with
assembled from the following pages:
Class: Str §
From Str
(Str) method starts-with §
multi method starts-with(Str: Str(Cool) , :i(:), :m(:) --> Bool)
Returns True
if the invocant is identical to or starts with $needle
.
say "Hello, World".starts-with("Hello"); # OUTPUT: «True» say "https://raku.org/".starts-with('ftp'); # OUTPUT: «False»
Since Rakudo version 2020.02, if the optional named parameter :ignorecase
, or :i
, is specified, the comparison of the invocant and $needle
ignores the distinction between upper case, lower case and title case letters.
say "Hello, World".starts-with("hello"); # OUTPUT: «False» say "Hello, World".starts-with("hello", :ignorecase); # OUTPUT: «True»
Since Rakudo 2020.02, if the optional named parameter :ignoremark
, or :m
, is specified, the comparison of the invocant and $needle
only considers base characters, and ignores additional marks such as combining accents.
say "abc".starts-with("ä"); # OUTPUT: «False» say "abc".starts-with("ä", :ignoremark); # OUTPUT: «True»