V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · Jul 13, 2024 · 2614 views
    This topic created in 659 days ago, the information mentioned may be changed or developed.

    nginx version: nginx/1.24.0

    4 replies    2024-07-14 17:47:45 +08:00
    JFZ
        1
    JFZ  
       Jul 13, 2024
    同样遇到
    itechify
        2
    itechify  
    PRO
       Jul 13, 2024
    双括号包一下试试?
    ltux
        3
    ltux  
       Jul 14, 2024 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
       Jul 14, 2024
    @oneisall8955
    @ltux

    可以了,,感谢。。

    结果 AI 也没能告诉我这个答案。。- -
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   975 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:41 · PVG 07:41 · LAX 16:41 · JFK 19:41
    ♥ Do have faith in what you're doing.