gpt4 book ai didi

regex - 正则表达式匹配从 PostgreSQL 8.3 到 9.2 有什么变化?

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

如果我运行这个查询:

SELECT 'Via Orologio 122 A' SIMILAR TO '(Strada|Via) % [0-9]+( [A-Z])?';

我希望得到 TRUE。 postgreSQL 9.1.8 版返回预期值,但在 8.3 版中返回 FALSE。我认为问题是最后的问号。事实上,查询:

SELECT 'Via Orologio 122 A' SIMILAR TO '(Strada|Via) % [0-9]+( [A-Z])';

在两个版本中都返回 TRUE。

谁知道这两个版本有什么区别?

最佳答案

来自 changelog of 8.3.2 :

Fix a corner case in regular-expression substring matching (substring(string from pattern)) (Tom)
The problem occurs when there is a match to the pattern overall but the user has specified a parenthesized subexpression and that subexpression hasn't got a match. An example is substring('foo' from 'foo(bar)?'). This should return NULL, since (bar) isn't matched, but it was mistakenly returning the whole-pattern match instead (ie, foo)

关于regex - 正则表达式匹配从 PostgreSQL 8.3 到 9.2 有什么变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15604407/

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