regex - Varnish 中的正则表达式?这个正则表达式匹配什么?

标签 regex varnish

我在日志中看到一个清除请求将 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/

相关文章:

python - 为什么 Django 不在 Varnish 代理后面生成 CSRF 或 session Cookie?

caching - Varnish :具有多个 IP 的后端(或使用其他东西)

php - laravel 中用于缓存的 varnish 等效包

regex - 用于属性、函数和子项的 VBA 正则表达式

javascript - 在javascript中使用正则表达式获取引号外的代码

python - 正则表达式匹配除字符串以外的所有内容

php - 在 php preg_replace 中允许点

centos - 无法在端口 80 CentOS v7.9.2009 kvm [ns] 上启动 Varnish - 错误 : -a arguments localhost:8443 and localhost:8443 have same address

Django性能

regex - Kibana 查询精确匹配