TLD 可能有多长?
我正在 PHP 中开发电子邮件验证正则表达式,我需要知道 TLD 可能持续多长时间并且仍然有效。我做了一些搜索,但找不到有关该主题的太多信息。那么 TLD 可能有多长?
I'm working on an email validation regex in PHP and I need to know how long the TLD could possibly be and still be valid. I did a few searches but couldn't find much information on the topic. So how long can a TLD possibly be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
DNS 允许单个标签最多使用 63 个字符。
DNS allows for a maximum of 63 characters for an individual label.
目前存在的最长 TLD 为 24 个字符,并且可能会发生变化。 RFC 1034 指定的最大 TLD 长度为 63 个八位字节。
要获取最长的现有 TLD 的长度:
该命令的作用如下:
wc
计算最长的行使用
curl
的替代方案感谢 Stefan:The longest TLD currently in existence is 24 characters long, and subject to change. The maximum TLD length specified by RFC 1034 is 63 octets.
To get the length of the longest existing TLD:
Here's what that command does:
wc
to count the longest lineAlternative using
curl
thanks to Stefan:-编辑-
根据 RFC 2606 .localhost 是保留域名,其长度为 9 个字符。
这是我所知道的最长的了。
-编辑结束-
但是,我认为您应该关心电子邮件地址长度而不仅仅是 TLD 长度。
以下是这篇文章的引用。
电子邮件地址长度为 254 个字符:
-EDIT-
According to RFC 2606 .localhost is reserved domain name and its length is 9 characters.
That is the longest I am aware of.
-END OF EDIT-
However, I think that you should care about email address length and not only TLD length.
Below is a quote from this article.
The email address length is 254 characters:
最长的拉丁字母是 .MUSEUM(来源),但也有一些带有特殊的人物。其中最长的是 XN--CLCHC0EA0B2G2A9GCD。此外,在短时间内,您可以以高价保留您自己的 TLD,因此时间可能会更长。
The longest with latin letters is .MUSEUM (source), but there are some with special characters. The longest from them is XN--CLCHC0EA0B2G2A9GCD. Also, in a short time, it will be possible to reserve your own TLD for a high price and so it will be possible to be longer.
由于我是一名 .net 开发人员,以下是确定当前可用的最长 TLD 的 java 脚本表示形式。这将返回您可以在 RegEx 中使用的最长 TLD 的长度。
请尝试以下代码片段
Since I'm a .net developer following is the java-script representation of determining the longest TLD currently available.this will return the length of the longest TLD which you would be able to use in your RegEx.
please try the following Code Snippet
迄今为止最长的 TLD 是.xn--vermgensberatung-pwb,在 Punycode 中为 24 个字符,解码后为 17 个[vermögensberatung]。如果没有 Punycode,则为 .northwesternmutual 或 .travelersinsurance,均为 18 个字符。
但是,域名(TLD 之前的内容)最长可达 63 个字符,如下所示: http: //www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com
Longest TLD up to date is .xn--vermgensberatung-pwb, at 24 characters in Punycode and 17 when decoded [vermögensberatung]. With no Punycode it would be .northwesternmutual or .travelersinsurance both at 18 characters.
However, a domain name, the thing that goes before an TLD, can be up to 63 characters long, as seen here: http://www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com
这是
PHP
代码,用于获取最新的竖线分隔的UTF-8
TLD 列表,以便直接在正则表达式中使用:要匹配您可以使用的主机名像这样:
This is
PHP
code to get up-to-date vertical bar separatedUTF-8
TLDs list to be used directly in a regular expression:To match a host name you could use it like this:
TLD 可以是任意长度。新顶级域名 (TLD) 一直在发生。将来将会有更多的 TLD 不受目前监管大多数 TLD 的实体的监管。我们将来也不会像现在一样使用电子邮件。也就是说:
您永远不需要验证电子邮件地址。如果您想让人们慢下来并了解他们是否真的是人类,请添加验证码。如果您需要确认工作电子邮件,请发送一封包含他们可以打开的验证链接的电子邮件。如果您不限制提交可能生成诸如发送验证电子邮件之类的内容,那么您是否确认该地址在技术上有效并不重要,无论如何,它都会在那时被滥用。
A TLD can be any length at all. New TLDs happen all the time. In the future there will be more TLDs not regulated by the entity currently regulating the majority of TLDs. We also won't use email in the future as we presently do. That said:
You don't need to validate an email address ever. If you want to slow people down and have an idea as to whether they're actually human, include a CAPTCHA. If you need to confirm working email, send an email with a validation link they can open. If you aren't throttling submissions of things that can generate things like emails being sent for verification, it won't matter whether you're confirming the address is technically valid anyway, it will be abused at that point regardless.