V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
wdssmq
V2EX  ›  NGINX

Nginx 配置中,正则中的 \d{10} 语法会报错,目测是花括号被识别为了语法块?

  •  
  •   wdssmq ·
    wdssmq · 56 天前 · 1517 次点击
    这是一个创建于 56 天前的主题,其中的信息可能已经有所发展或是发生改变。

    nginx version: nginx/1.24.0

    4 条回复    2024-07-14 17:47:45 +08:00
    jiuhuicinv
        1
    jiuhuicinv  
       56 天前
    同样遇到
    oneisall8955
        2
    oneisall8955  
       56 天前
    双括号包一下试试?
    ltux
        3
    ltux  
       55 天前 via Android   ❤️ 1
    含有大括号的正则表达式需要用双引号引起来。

    A regular expression containing the characters “{” and “}” should be quoted:

    server_name "~^(?<name>\w\d{1,3}+)\.example\.net$";
    wdssmq
        4
    wdssmq  
    OP
       55 天前
    @oneisall8955
    @ltux

    可以了,,感谢。。

    结果 AI 也没能告诉我这个答案。。- -
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1122 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:44 · PVG 07:44 · LAX 16:44 · JFK 19:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.