我正在尝试为路径设置正则表达式/s/<4-6 character string here>
我将 4-6 个字符串捕获为 $1。
我尝试使用以下两个条目,但都失败了
location ~ ^/s/([0-9a-zA-Z]){4,6}+$ { ...
location ~ ^/s/([0-9a-zA-Z]{4,6})+$ { ...
第一个出现“未知指令”,第二个出现“pcre_compile()失败:丢失)”
EDIT
该地点将服务以下路线:
/s/1234 (and I would capture '1234' in $1)
/s/12345 (and I would capture '12345' in $1)
/s/123456 (and I would capture '123456' in $1)
/s/abcd (and I would capture 'abcd' in $1)
/s/abcde (and I would capture 'abcde' in $1)
/s/abcdef (and I would capture 'abcdef' in $1)
/s/a1b2c (and I would capture 'a1b2c' in $1)
此地点不提供以下路线服务:
/s/1
/s/12
/s/123
/s/a
/s/ab
/s/abc
/s/abc1234
/s/12345678
etc...
如果要捕获 4 到 6 个字符,为什么不将量词放在捕获括号内?
也许是这样的:
location ~ "^/s/([0-9a-zA-Z]{4,6})$" {...
大括号在正则表达式和块控制中都使用,您必须用引号(单引号或双引号)将正则表达式括起来(
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)