我在我的日誌中看到清除請求將以
req.url ~ "^(.*)(?<!\\d{1})534328(?!\\d{1})"
的形式清除。我不確定正則表達式匹配的是什麼。我知道清漆使用POSIX正則表達式。我正在嘗試爲正則表達式^(.*)(?<!\\d{1})534328(?!\\d{1})
生成示例匹配,但無法爲我提供工具。在光油中的正則表達式?這個正則表達式匹配什麼?
編輯:對不起,我提出根據changelog here.
我在我的日誌中看到清除請求將以
req.url ~ "^(.*)(?<!\\d{1})534328(?!\\d{1})"
的形式清除。我不確定正則表達式匹配的是什麼。我知道清漆使用POSIX正則表達式。我正在嘗試爲正則表達式^(.*)(?<!\\d{1})534328(?!\\d{1})
生成示例匹配,但無法爲我提供工具。在光油中的正則表達式?這個正則表達式匹配什麼?
編輯:對不起,我提出根據changelog here.
它匹配534328
既不是一個數字,前面和後面一個錯誤The regular expression engine is now PCRE instead of POSIX regular expressions.
。
^ # line beginning
(.*) # any character repeated any number of times, including 0
(?<!\d{1}) # negative look-behind assertion: single digit
534328 # literal 534328
(?!\d{1}) # negative look-ahead assertion: single digit
"whatever 534328" ← match
"wharrgarbl 1534328" ← no match
"any chars 5343289" ← no match
"hello world a534328b" ← match
不需要冒號但是它會在行尾是否匹配534328? – 2013-04-25 18:50:21
咦?這些僅僅是一個表格中的例子。好的,我會重新格式化它。 – 2013-04-25 18:51:04
@LeeMeador:是的。 – 2013-04-25 19:08:00
如果光油不使用POSIX正則表達式,那麼這個正則表達式是行不通的,因爲環視斷言不被POSIX正則表達式的支持。 – 2013-04-25 18:57:32
[Varnish使用PCRE](https://www.varnish-cache.org/docs/trunk/reference/vcl.html#regular-expressions)。 – 2013-04-25 18:59:52
對不起,我編輯了這個問題。 – awm 2013-04-25 19:04:14