Ruby 4.1 リファレンスマニュアル

instance method String#start_with?

start_with?(*prefixes) -> bool[permalink][rdoc][edit]

self の先頭が prefixes のいずれかであるとき true を返します。

[PARAM] prefixes:
パターンを表す文字列または正規表現 (のリスト)
p "string".start_with?("str")        # => true
p "string".start_with?("ing")        # => false
p "string".start_with?("ing", "str") # => true
p "string".start_with?(/\w/)         # => true
p "string".start_with?(/\d/)         # => false

[SEE_ALSO] String#end_with?

[SEE_ALSO] String#delete_prefix, String#delete_prefix!