在Greasemonkey @include中使用正则表达式?

Jak*_*sed 5 regex greasemonkey

我想在我的Greasemonkey脚本运行的地方更好地指定一下.

// @include     https://example.com/*
Run Code Online (Sandbox Code Playgroud)

工作正常,但它太不准确,我想要的东西像:

// @include     https://example.com/xx-xx/Asset/*
Run Code Online (Sandbox Code Playgroud)

xx可以是任何字母az, - 只是短划线,xx可以是任何字母az.我的想法是使用任何5个符号的正则表达式,但我不知道如何正确使用它.这不起作用,我尝试过更多的表达:

// @include     https://example.com/...../Asset/*
Run Code Online (Sandbox Code Playgroud)

知道如何处理这个?

更新:
这种作品:

// @include     https://example.com/*/Asset/*
Run Code Online (Sandbox Code Playgroud)

Bro*_*ams 9

请参阅Greasemonkey文档中的包含和排除规则.
*是一个特殊的通配符,不是通常的JavaScript规则.
要使用全功能正则表达式,Greasemonkey提供了一种特殊的语法@include.

所以你的https://example.com/xx-xx/Asset/*模式会变成:

// @include  /^https:\/\/example\.com\/[a-z]{2}\-[a-z]{2}\/Asset\/.*$/
Run Code Online (Sandbox Code Playgroud)


您可以在RegExr.com上看到该正则表达式的解释.