postgresql 中的正则表达式
我有一个包含以下三行的表现
name
----------------------------------------------
user - help center test 4 [120,2010-08-19]
test - help center test 2 [123,2010-01-19]
help center test [20109,2010-01-01]
(3 rows)
在我需要获得“帮助中心测试”的精确匹配,因此它应该返回第三行。我基本上需要进行完全匹配,就好像 [20109,2010-01-01] 不存在于 帮助中心测试 [20109,2010-01-01] 中,因此消除括号和括号内的所有内容。注意括号内的结果可以是任何结果。
如果括号不存在,我会使用类似的东西 SELECT name FROM client WHERE lower(name) like '%call center test%'
这会给我结果,但现在我需要对上面的结果做同样的事情?这可能吗?
I have a table that contains the following three rows
name
----------------------------------------------
user - help center test 4 [120,2010-08-19]
test - help center test 2 [123,2010-01-19]
help center test [20109,2010-01-01]
(3 rows)
Now i need to get a exact match of "help center test" thus it should return the 3rd row. I basically need to do this exact match as if [20109,2010-01-01] does not exist in help center test [20109,2010-01-01] thus eliminating the brackets and everything within the brackets. NOte the result within the bracket could be anything.
If the brackets weren't there I would use something likeSELECT name FROM clients WHERE lower(name) like '%call center test%'
and that would give me the result but now I need to do the same with the above results? Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据: http://www.postgresql.org/docs/8.1/ static/functions-matching.html :
只是为了澄清 ~* 是不区分大小写的匹配,因此不需要对名称进行 lower() 函数调用。这将匹配所有以“help center test [”开头,然后有 n 个字符,最后以“]”结尾的行(当然,两者都没有双引号)。
According to: http://www.postgresql.org/docs/8.1/static/functions-matching.html :
Just to clarify that the ~* is a case insensitive match, so there's no need for the lower() function call on the name. This will match all rows that start "help center test [" then have n characters and finally end with "]" (both without double quotes, of course).