正则表达式匹配中从PostgreSQL 8.3到9.2的变化是什么?

前端之家收集整理的这篇文章主要介绍了正则表达式匹配中从PostgreSQL 8.3到9.2的变化是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我运行此查询

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

我希望得到真实. 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)

猜你在找的正则表达式相关文章