【发布时间】:2014-10-20 00:27:32
【问题描述】:
我有一个包含 4 行的表格,如下所示:
Audit\\subfolder\System2.log
Audit\\subfolder/System1.log
Audit\\System2.log
Audit\\System1.log
运行以下查询:
select * from table where file_location SIMILAR TO '审核\\[^/]*'
将产生:
Audit\\subfolder\System2.log
Audit\\System2.log
Audit\\System1.log
但是运行以下查询:
select * from table where file_location SIMILAR TO '审核\\[^\\]*'
什么也没给我。
在SIMILAR TO 子句中转义\\ 的正确方法是什么?
【问题讨论】:
-
SIMILAR TO是 IMO 浪费时间。只需将与 perl 兼容的正则表达式与~一起使用。
标签: postgresql