ILIKE匹配Word边界PostgreSQL 9 [英] ILIKE Match Word Boundaries PostgreSQL 9
本文介绍了ILIKE匹配Word边界PostgreSQL 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PostgreSQL 9中使用LIKE / ILIKE运算符时,可以匹配单词边界而无需使用完整的〜运算符正则表达式吗? 例如 p>
选择'超快速训练'ILIKE'%train \M%'作为匹配;
其中\M是单词末尾的边界,匹配返回 false
感谢,
标记
解决方案
你可以用下面的方法做到这一点:
SELECT''|| '超级快速训练'ILIKE'%train%'
但我并不认为这是个好主意。您可以使用正则表达式或PostgreSQL全文。 PostgreSQL正则表达式不会比ILIKE或LIKE慢很多。
When using the LIKE/ILIKE operator in PostgreSQL 9 is it possible to match word boundaries without having to use full blown ~ operator regular expressions?
For example
SELECT 'Super fast training' ILIKE '%train\M%' as match;
Where \M is the boundary at the end of a word and match returns false
Thanks,
Mark
解决方案
you can do it with following trick:
SELECT ' ' || 'Super fast training' ILIKE '%train %'
but I don't hink so it is a good idea. You can use regular expression or PostgreSQL fulltext instead. PostgreSQL regular expressions are not significantly slower than ILIKE or LIKE.
这篇关于ILIKE匹配Word边界PostgreSQL 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文