加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 05:49:51 所属栏目:百科 来源:网络整理
导读:如果我运行此查询: 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 T
如果我运行此查询:

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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读