本文介绍了android.util.Patterns.EMAIL_ADDRESS正在验证无效的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些电子邮件无效。

我已经检查了以下网站中的上述电子邮件,所有返回的内容均无效。

I have checked above emails in following websites, All of those returns invalid.http://isemail.info/abouthttp://sqa.fyicenter.com/Online_Test_Tools/Email_Address_Format_Validator.php.

但是, android.util.Patterns.EMAIL_ADDRESS 模式会同时验证这两者。

Yet, android.util.Patterns.EMAIL_ADDRESS pattern validates both.

是否存在错误或我错过了什么吗?

Is there a bug or am I missing something?

推荐答案

两个似乎都是有效的电子邮件地址

Both seems to be valid email addresses

email@domain.web

.email @ domain.com

因为任何电子邮件地址都包含三个组成部分

since any email address contains three components

<username>@<mail-server>.<mail-servertype or server-location>

此处 android.util.Patterns.EMAIL_ADDRESS 使用正则表达式验证所有三个组件,并检查所有三个组件是否放置正确。一些常见的令人困惑的示例是:

Here android.util.Patterns.EMAIL_ADDRESS validates all the three components using regex and also checks if all three components are placed properly. Some common confusing examples are:


  1. com@web123.com is有效的邮件地址,因为 com 可以是用户名,而 web123 可以是Web服务器的名称。

  1. com@web123.com is a valid mail address since com can be a user name and web123 can be a web server's name.

.maths.apple @ com.in 也是有效的邮件地址,因为 .maths .apple 可以是用户名, com 可以是Web服务器的名称。

.maths.apple@com.in is also a valid mail address since .maths.apple can be a user name and com can be a web server's name.



无效的情况:



crick @ .web.com 无效,因为不能在 @ 之前或之后。没有邮件系统能够识别用户名或邮件服务器名称。

Invalid case:

crick@.web.com is invalid since a . cannot come before or after @. No mailing system will be able to recognize the username or mail-server name.

这篇关于android.util.Patterns.EMAIL_ADDRESS正在验证无效的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 06:19