Does Rails 3 or Ruby have a built in way to return true or false on if a var is an EMAIL ADDRESS?
example
1 returns false
[email protected] returns true
[email protected] returns true
asdasdasdads returns false
Maybe something like, if 1.is_a? Email end
thanks
I ended up using the Rails gem, EmailVeracity which worked great
Something like this should work:
def isEmail(str)
return str.match(/[a-zA-Z0-9._%]@(?:[a-zA-Z0-9]\.)[a-zA-Z]{2,4}/)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With