method
start_with?
v1_8_7_330 -
Show latest stable
- Class:
String
start_with?(...)public
Returns true if str starts with the prefix given.
2Notes
Starts with a Capital Letter
(or any regular expression you'd like)
'Abracadabra'[0..0] =~ /[A-Z]/ # => true
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]/