Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 内容脚本模式匹配_Javascript_Google Chrome_Google Chrome Extension_Google Chrome App - Fatal编程技术网

Javascript 内容脚本模式匹配

Javascript 内容脚本模式匹配,javascript,google-chrome,google-chrome-extension,google-chrome-app,Javascript,Google Chrome,Google Chrome Extension,Google Chrome App,我正在寻找一种方法来匹配url路径上的某些模式,该路径应该调用我的Chrome扩展的内容脚本。我已经阅读了文档,但是我找不到如何匹配以下场景: http://mypage.com/some/sub/path - should match http://mypage.com/some/sub/ - should not match 其中as path可以是任何东西。。我试过了 http://mypage.com/some/sub/* 但这似乎也涵盖了 有没有办法使用正则表达式进行模式匹

我正在寻找一种方法来匹配url路径上的某些模式,该路径应该调用我的Chrome扩展的内容脚本。我已经阅读了文档,但是我找不到如何匹配以下场景:

http://mypage.com/some/sub/path - should match
http://mypage.com/some/sub/     - should not match
其中as path可以是任何东西。。我试过了

http://mypage.com/some/sub/*
但这似乎也涵盖了

有没有办法使用正则表达式进行模式匹配?规则应该是:匹配任何以开头并后跟至少一个字符的url

解决方案是
“排除匹配”


你试过
http://mypage.com/some/sub/+
?该url的正则表达式后跟任何字符将是/http\:\/\/mypage\.com\/some\/sub\/./@ackerman不幸的是,它不是正则表达式。
"content_scripts": [
  {
    "matches": ["http://mypage.com/some/sub/*"],
    "exclude_matches": ["http://mypage.com/some/sub/"],
    "js": ["myscript.js"]
  }
],