If you mean checking if first element in string is letter, you could do:
string[0].match(/[a-zA-Z]/)
or, as Arup Rakshit suggested, you can use i
option in your regexp to ignore case:
string[0].match(/[a-z]/i)
These lines will return either MatchData
if tested string starts with letter or nil
if it doesn't. If you want true
and false
values, you can do:
!!string[0].match(/[a-z]/i)