<small id='JV3ta'></small><noframes id='JV3ta'>

    1. <i id='JV3ta'><tr id='JV3ta'><dt id='JV3ta'><q id='JV3ta'><span id='JV3ta'><b id='JV3ta'><form id='JV3ta'><ins id='JV3ta'></ins><ul id='JV3ta'></ul><sub id='JV3ta'></sub></form><legend id='JV3ta'></legend><bdo id='JV3ta'><pre id='JV3ta'><center id='JV3ta'></center></pre></bdo></b><th id='JV3ta'></th></span></q></dt></tr></i><div id='JV3ta'><tfoot id='JV3ta'></tfoot><dl id='JV3ta'><fieldset id='JV3ta'></fieldset></dl></div>

    2. <legend id='JV3ta'><style id='JV3ta'><dir id='JV3ta'><q id='JV3ta'></q></dir></style></legend>
      <tfoot id='JV3ta'></tfoot>
      • <bdo id='JV3ta'></bdo><ul id='JV3ta'></ul>

        正确匹配 IDN URL

        Properly Matching a IDN URL(正确匹配 IDN URL)
      1. <i id='yY5fs'><tr id='yY5fs'><dt id='yY5fs'><q id='yY5fs'><span id='yY5fs'><b id='yY5fs'><form id='yY5fs'><ins id='yY5fs'></ins><ul id='yY5fs'></ul><sub id='yY5fs'></sub></form><legend id='yY5fs'></legend><bdo id='yY5fs'><pre id='yY5fs'><center id='yY5fs'></center></pre></bdo></b><th id='yY5fs'></th></span></q></dt></tr></i><div id='yY5fs'><tfoot id='yY5fs'></tfoot><dl id='yY5fs'><fieldset id='yY5fs'></fieldset></dl></div>
          <bdo id='yY5fs'></bdo><ul id='yY5fs'></ul>
        • <small id='yY5fs'></small><noframes id='yY5fs'>

            <tfoot id='yY5fs'></tfoot>
                  <legend id='yY5fs'><style id='yY5fs'><dir id='yY5fs'><q id='yY5fs'></q></dir></style></legend>
                    <tbody id='yY5fs'></tbody>
                  本文介绍了正确匹配 IDN URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要帮助构建一个可以正确匹配自由文本中的 URL 的正则表达式.

                  • 方案
                    • 以下之一:ftphttphttps(ftps 是协议吗?)
                    • scheme
                      • One of the following: ftp, http, https (is ftps a protocol?)
                      • 支持www子域(支持 IDN)
                      • TLD 的基本过滤(我认为 [a-zA-Z]{2,6} 就足够了)
                      • support for www and sub-domain(s) (with support for IDNs)
                      • basic filtering of TLDs ([a-zA-Z]{2,6} is enough I think)

                      以下是关于子域的信息:

                      Here is what I could find out about sub-domains:

                      子域"表示相对依赖,而不是绝对依赖:例如,wikipedia.org 包括一个org 域的子域,以及en.wikipedia.org 包含一个子域wikipedia.org 域的名称.在理论上,这个细分可以下降到 127 层深,每个 DNS 标签最多可以包含 63 个字符,如只要整个域名不总长度超过 255字符.

                      A "subdomain" expresses relative dependence, not absolute dependence: for example, wikipedia.org comprises a subdomain of the org domain, and en.wikipedia.org comprises a subdomain of the domain wikipedia.org. In theory, this subdivision can go down to 127 levels deep, and each DNS label can contain up to 63 characters, as long as the whole domain name does not exceed a total length of 255 characters.

                      关于域名本身,我找不到任何可靠的来源,但我认为非 IDN 的正则表达式(我不确定如何编写 IDN 兼容版本)类似于:

                      Regarding the domain name itself I couldn't find any reliable source but I think the regular expression for non-IDNs (I'm not sure how to write a IDN compatible version) is something like:

                      [0-9a-zA-Z][0-9a-zA-Z-]{2,62}
                      

                      有人能帮我解决这个正则表达式或给我指明一个好的方向吗?

                      推荐答案

                      因 Daring Fireball 成名的 John Gruber,拥有 最近的一篇文章 详细介绍了他对一个良好的 URL 识别正则表达式字符串的追求.他想出了这个:

                      John Gruber, of Daring Fireball fame, had a post recently that detailed his quest for a good URL-recognizing regex string. What he came up with was this:

                      <代码>(([w-]+://?|www[.])[^s()<>]+(?:([wd]+)|([^[:punct:]s]|/)))

                      这显然也适用于包含 Unicode 的 URL.您需要对其稍作修改以获得您正在寻找的其余内容——方案、用户名、密码等. Alan Storm 写了一篇解释 Gruber 的正则表达式模式的文章,我绝对需要它(正则表达式是如此写一次,没有线索,如何再读一次!).

                      Which apparently does OK with Unicode-containing URLs, as well. You'd need to do the slight modification to it to get the rest of what you're looking for -- the scheme, username, password, etc. Alan Storm wrote a piece explaining Gruber's regex pattern, which I definitely needed (regex is so write-once-have-no-clue-how-to-read-ever-again!).

                      这篇关于正确匹配 IDN URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <bdo id='ar1In'></bdo><ul id='ar1In'></ul>

                      <i id='ar1In'><tr id='ar1In'><dt id='ar1In'><q id='ar1In'><span id='ar1In'><b id='ar1In'><form id='ar1In'><ins id='ar1In'></ins><ul id='ar1In'></ul><sub id='ar1In'></sub></form><legend id='ar1In'></legend><bdo id='ar1In'><pre id='ar1In'><center id='ar1In'></center></pre></bdo></b><th id='ar1In'></th></span></q></dt></tr></i><div id='ar1In'><tfoot id='ar1In'></tfoot><dl id='ar1In'><fieldset id='ar1In'></fieldset></dl></div>

                            <small id='ar1In'></small><noframes id='ar1In'>

                              <tbody id='ar1In'></tbody>
                          1. <legend id='ar1In'><style id='ar1In'><dir id='ar1In'><q id='ar1In'></q></dir></style></legend>

                            <tfoot id='ar1In'></tfoot>