我在日志中看到一个清除请求将 Varnish 表单
req.url ~ "^(.*)(?<!\\d{1})534328(?!\\d{1})"
。我不确定正则表达式完全匹配什么。我知道 varnish 使用 POSIX 正则表达式。我正在尝试为正则表达式 ^(.*)(?<!\\d{1})534328(?!\\d{1})
生成示例匹配但无法找到一个很好的工具来帮助我。
编辑:抱歉,我犯了一个错误 The regular expression engine is now PCRE instead of POSIX regular expressions.
根据changelog here.
最佳答案
它与前面和后面都没有数字的 534328
匹配。
^ # 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
关于regex - Varnish 中的正则表达式?这个正则表达式匹配什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16222388/