nginx 正则表达式和 openresty
nginx regexp and openresty
我的 nginx 应该匹配这些请求:
- /id/12345
- /id/12345/限定符
和/qualifier应该是可选的。
我想在一个小的 lua openresty 脚本中使用两个匹配的组(12345,限定符)与 ngx.var[]
我正在尝试使用此位置,但对我不起作用。
我怎么能说 / 和 qualifier 是可选的?
location ~ ^/id/(\d+)(/?)(\w+?)$ {
^/id/(\d+)(?:/(\w+))?$
(?:) 是一个 non-capturing 组。
我的 nginx 应该匹配这些请求:
- /id/12345
- /id/12345/限定符
和/qualifier应该是可选的。
我想在一个小的 lua openresty 脚本中使用两个匹配的组(12345,限定符)与 ngx.var[]
我正在尝试使用此位置,但对我不起作用。 我怎么能说 / 和 qualifier 是可选的?
location ~ ^/id/(\d+)(/?)(\w+?)$ {
^/id/(\d+)(?:/(\w+))?$
(?:) 是一个 non-capturing 组。