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

joshuapinter · May 2, 2012

(or any regular expression you'd like)

'Abracadabra'[0..0] =~ /[A-Z]/       # => true

Starts with capital letter alternative

citizen428 · May 17, 2012

Just adding an anchor to the regular expression seems simpler (and was faster in my benchmarks, not that that matters much):

'Abracadabra' =~ /^[A-Z]/