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

标签 javascript regex firefox gecko address-bar

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

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

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

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

^ symbol

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

Dollar Symbol

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

parenthesis symbols

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

Star symbol

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

Tilde symbol

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

-

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

最佳答案

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

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

  1. 选择要搜索的内容。这是通过选中 browser.urlbar.default.behavior 来完成的。偏好以及寻找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. 搜索内容时,每个以空格分隔的字符序列(上述特殊字符除外)必须出现在其文本(网站标题、URL 等)中,不区分大小写。 (序列可能重叠。)

关于javascript - Firefox URL 栏使用什么正则表达式模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34368889/

相关文章:

javascript - 独立获取nodejs中的当前请求(?)

javascript - react 应用程序 : D3 Chart not showing up

python - Python 循环中的正则表达式

Java Regex - 减少字符串中的空格

jQuery 代码在 Safari 中工作,但在 Firefox 中不工作

google-chrome - 匿名代理不仅仅适用于 Firefox。对于 Chrome - 确定

html - plupload跨域上传200 http错误

javascript - Google Maps V3 Circle 和我创建的 Circle 不匹配

javascript - JQuery - 计算从今天起 5 年后的日期和月份

hgignore 文件中的正则表达式负向后视