ruby/doc/string/start_with_p.rdoc
2025-12-27 10:59:48 -05:00

17 lines
605 B
Plaintext

Returns whether +self+ starts with any of the given +patterns+.
For each argument, the pattern used is:
- The pattern itself, if it is a Regexp.
- <tt>Regexp.quote(pattern)</tt>, if it is a string.
Returns +true+ if any pattern matches the beginning, +false+ otherwise:
'hello'.start_with?('hell') # => true
'hello'.start_with?(/H/i) # => true
'hello'.start_with?('heaven', 'hell') # => true
'hello'.start_with?('heaven', 'paradise') # => false
'こんにちは'.start_with?('こ') # => true
Related: see {Querying}[rdoc-ref:String@Querying].