blob: 298a5572769ea83bd9b0be7d8c0c30fd50d4aca6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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
'こんにちは'.start_with?('こ') # => true
Related: see {Querying}[rdoc-ref:String@Querying].
|