gpt4 book ai didi

regex - Reg.ex 模式匹配在 postgresql 中不起作用

转载 作者:行者123 更新时间:2023-11-29 12:49:46 26 4
gpt4 key购买 nike

我有这个选择查询,它使用与大字符串内容中的字符串匹配的正则表达式。

不知何故,当我在 pgadmin 中运行它时,它没有产生任何结果。但是当我在其他正则表达式匹配工具中测试时,相同的模式匹配所需的。

select count(DEVICE.DeviceID) from DEVICE 
where ('!
redundancy
!
vlan internal allocation policy ascending
!' ~* '^redundancy$')

我期望匹配模式,因为字符串“redundancy”存在于一行中。

最佳答案

您需要指定 newline-sensitive matching :

m   historical synonym for n
n newline-sensitive matching

If newline-sensitive matching is specified, . and bracket expressions using ^ will never match the newline character (so that matches will never cross newlines unless the RE explicitly arranges it) and ^ and $ will match the empty string after and before a newline respectively, in addition to matching at beginning and end of string respectively. But the ARE escapes \A and \Z continue to match beginning or end of string only.

使用其中之一

'(?m)^redundancy$'

'(?n)^redundancy$'

关于regex - Reg.ex 模式匹配在 postgresql 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57039286/

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