Everything seems to be working fine except the commented line:
#return false if not s[0].upcase =~ /AZ/
and the fourth check.
What is t
I'm also not sure what your regex is trying to achieve, so I can't suggest a fix. But for the entire method, I'd keep it simple by using the === operator and making the regex case-insensitive with the i
option:
def starts_with_consonant?(s)
/^[bcdfghjklmnpqrstvwxyz]/i === s
end
It's easy with regex:
def starts_with_consonant?(s)
!!(s =~ /^[bcdfghjklmnpqrstvwxyz]/i)
end
This matches the first character of the string with the set of consonants. The !!
forces the output to true/false.
This works too
def starts_with_consonant? s
return /^[^aeiou]/i === s
end
try this...
def starts_with_consonant? s
/^[^aeiou\d\W]/i =~ s ? true : false
end