validate_email = ( email ) ->
(/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/).test email
这可行,但它在 79 个字符时未能通过我的“最大行长度”测试,因此我一直在尝试使用 coffeescript.org 上的示例将其减少到少于 80 个字符(实际上最多 74 个):
RFC822 = /// ^ (
([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+
| \x22([^\x0d\x22\x5c\x80-\xff]
| \x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a
-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+
| \x22([^\x0d\x22\x5c\x80-\xff]
| \x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a
-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+
| \x5b([^\x0d\x5b-\x5d\x80-\xff]
| \x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a
-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+
| \x5b([^\x0d\x5b-\x5d\x80-\xff]
| \x5c[\x00-\x7f])*\x5d))*$/
) ///
RFC822.test email
虽然这编译得很好,但它不起作用。它总是返回假。
我该怎么做呢?