在 Dart 中验证电子邮件地址? [英] Validate email address in Dart?

查看:85
本文介绍了在 Dart 中验证电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 RegExp 文档,我们必须使用 JavaScript (Perl 5) 正则表达式:ECMA 规范.您在 Dart 中使用什么模式进行电子邮件验证?在 Dart 中,是否有与 JavaScript 不同的方法来实现这一点?

According to RegExp documentation, we must use JavaScript (Perl 5) regular expressions : ECMA Specification. What pattern do you use for email validation in Dart? Is there any different way than JavaScript to achieve this in Dart?

推荐答案

我建议每个人都标准化 HTML5 电子邮件验证规范,该规范与 RFC822 不同,它禁止使用电子邮件地址的几个非常不常用的功能(例如评论!),但可以被正则表达式识别.

I'd recommend everyone standardize on the HTML5 email validation spec, which differs from RFC822 by disallowing several very seldom-used features of email addresses (like comments!), but can be recognized by regexes.

以下是 HTML5 规范中有关电子邮件验证的部分:http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29

Here's the section on email validation in the HTML5 spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29

这是正则表达式:

^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$

这篇关于在 Dart 中验证电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆