method
start_with?
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
start_with?(*args)
public
Returns true if str starts with one of the prefixes given.
p "hello".start_with?("hell") #=> true # returns true if one of the prefixes matches. p "hello".start_with?("heaven", "hell") #=> true p "hello".start_with?("heaven", "paradise") #=> false
Register or
log in
to add new notes.
joshuapinter -
May 3, 2012
citizen428 -
May 17, 2012
![Default_avatar_30](https://www.gravatar.com/avatar/6e6e22d81a1f4f394f62301be40c2e20?default=http://apidock.com/images/default_avatar_30.png&size=30)
0 thanks
Starts with a Capital Letter
(or any regular expression you’d like)
'Abracadabra'[0..0] =~ /[A-Z]/ # => true
![Default_avatar_30](https://www.gravatar.com/avatar/b3881a28fe402dd2d1de44717486cae8?default=http://apidock.com/images/default_avatar_30.png&size=30)
0 thanks
Starts with capital letter alternative
Just adding an anchor to the regular expression seems simpler (and was faster in my benchmarks, not that that matters much):
'Abracadabra' =~ /^[A-Z]/