summaryrefslogtreecommitdiff
path: root/doc/string/start_with_p.rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/string/start_with_p.rdoc')
-rw-r--r--doc/string/start_with_p.rdoc16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/string/start_with_p.rdoc b/doc/string/start_with_p.rdoc
new file mode 100644
index 0000000000..f78edc7fa3
--- /dev/null
+++ b/doc/string/start_with_p.rdoc
@@ -0,0 +1,16 @@
+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].