gpt4 book ai didi

postgresql - ^ 和 $ 在 nginx.conf 位置做什么?

转载 作者:行者123 更新时间:2023-11-29 12:44:24 25 4
gpt4 key购买 nike

location ~ ^/test/(?<id>\d+)$ {
postgres_pass database;
rds_json on;
postgres_escape $name $id;
postgres_query "SELECT $name";
}

上面的代码片段取自https://github.com/FRiCKLE/ngx_postgres/issues/4 .

有人可以向我解释一下 ^ 和 $ 的作用吗?我找不到解释它的文档。勾选https://github.com/FRiCKLE/ngx_postgreshttp://nginx.org/en/docs/http/ngx_http_core_module.html#location已经。

最佳答案

这是一个正则表达式。谷歌正则表达式。

^ 匹配字符串的开头,$ 匹配结尾。换句话说,只有 ^$ 之间的部分与 location 的所有值匹配时,此正则表达式才匹配。因此,只有以 /test/ 开头,后跟一个或多个数字和字符串结尾的 URL 才会匹配。

关于postgresql - ^ 和 $ 在 nginx.conf 位置做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32815570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com