Firefox URL 栏使用什么正则表达式模式?

What regex pattern does Firefox URL bar use?

我实际上是在使用正则表达式模式匹配和其他东西解决问题(搜索问题)。我想我会看看 Google、Yahoo、Bing、Ask 等的行为方式。

考虑到 Firefox、Chrome、Opera 和其他浏览器也有 URL 栏或搜索栏,我开始尝试不同的单词,然后是符号。

在 Firefox 中,我看到了很多不同的结果。这是一些截图-

^ Symbol - 给出一些随机结果。

$ Symbol - 也给出了随机结果。我也尝试用它添加一个字符串,但没有结果。

() 圆括号 - 使用时会给出正确的结果。它被认为是比较类似字符串的符号。

* Symbol - 这也给出了一组与符号本身不匹配的结果。不确定为什么会有这些不同的结果。

~ Symbol - 这也给出了一组与符号本身不匹配的结果。不确定为什么会有这些不同的结果。

我很想知道为什么许多符号的行为存在如此差异,而其他字符串 and/or 符号按预期工作。

-

@thanksd 不是 duplicate。这就是字符串匹配的工作原理。我已经知道那部分了。我清楚地询问符号。如何考虑符号进行匹配。

没有主流浏览器将您在其地址栏中键入的内容解释为正则表达式,因为普通用户不知道正则表达式。

这就是 Firefox 的工作方式(基本上):

  1. 选择要搜索的内容。这是通过检查 browser.urlbar.default.behavior preference as well as looking for special characters in the query:

    You can restrict what kind of results are shown in the drop down list by using customizable characters. Include the character anywhere in the address bar separated by spaces to have it restrict what results are displayed.

    The characters are as follows:

    • #: Returns results that match the text in the title.
    • @: Returns results that match the text in the URL.
    • *: Returns only results that are from the bookmarks.
    • ^: Returns only results that are from the browser’s history.
    • +: Returns only results that have been tagged.
    • ~: Returns only results that have been typed.
    • %: Returns only open tabs (visible tabs, not active tab), available in Firefox 4 (SeaMonkey 2.1) and later
  2. 搜索内容时,每个 whitespace-separated 字符序列(上述特殊字符除外)必须出现在其文本中(网站标题、URL 等) , 不区分大小写。 (序列可能重叠。)