我正在寻找一个正则表达式验证一个电子邮件,以了解它是否有效.我有以下:
def is_a_valid_email?(email) email_regex = %r{ ^ # Start of string [0-9a-z] # First character [0-9a-z.+]+ # Middle characters [0-9a-z] # Last character @ # Separating @ character [0-9a-z] # Domain name begin [0-9a-z.-]+ # Domain name middle [0-9a-z] # Domain name end $# End of string }xi # Case insensitive (email =~ email_regex) end
上述问题是XXX_XXX@Xxx.com不应该返回有效.对更好的正则表达式的任何想法或建议?
谢谢