A simple regex for email validation
VALID_EMAIL_REGEX= /^(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})$/i
validates :email , presence: true,uniqueness:{case_sensetive:false},
format:{with:VALID_EMAIL_REGEX,multiline:true}
view it on rubular
https://rubular.com/r/DofEroQvHSXNIw
Top comments (2)
I'd highly suggest NOT using regular expressions for email address syntax validation. The RFC allows for a lot more characters and variance in the email address than what is presented in this particular regular expression, meaning you'll end up excluding some users. And worse, others unaware of this will invariably end up on this article to copy-paste your regex into their application, which will end up them excluding others without even knowing it.
davidcel.is/posts/stop-validating-...
Fails to validate:
xxx.xxx+@xxx.xxx