gpt4 book ai didi

regex - 如何在Elasticsearch中写正则表达式查询,该查询匹配除斜杠以外的任何字符?

转载 作者:行者123 更新时间:2023-12-03 01:45:40 26 4
gpt4 key购买 nike

我对以下查询有疑问:

"query": {
"regexp": {
"rest.request.uri": {
"value": "/account/.*./price/.*./pdf"
}
}
}

它只能与以下情​​况匹配:/ account / {account_id} / price / {price_id} / pdf

这意味着*应该仅替换id,但是它将替换例如之间的所有内容。

/ account / {account_id} / sometext / price / {price_id} / sometext / pdf

有人知道如何解决吗?提前致谢。

最佳答案

模式:

account/[^/]+/price/[^/]+/pdf

此模式使用“否定的字符类”,它使正则表达式引擎运行得非常有效。

Wiktor说ES不需要转义的斜杠。给我的消息。

关于regex - 如何在Elasticsearch中写正则表达式查询,该查询匹配除斜杠以外的任何字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44153147/

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