正则表达式和文本匹配问题 [英] Regex and textmatching issue
本文介绍了正则表达式和文本匹配问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Postgres 9.3.5.0中进行一些基本的文本匹配。
这是到目前为止的代码:
I am doing some basic text matching in Postgres 9.3.5.0.
Here is my code so far:
Select text from eightks
WHERE other_events = true and
keywordRegexs = [\y(director and member \s+ and resigned)\y/ix];
我遇到以下错误
psql:test3.sql:3: invalid command \y(director
psql:test3.sql:5: ERROR: syntax error at or near "["
LINE 3: keywordRegexs = [
我正在尝试查找包含这些确切短语的文档。
I am trying to find documents which contain those exact phrases.
推荐答案
Postgres中的正则表达式匹配运算符为 〜
。
不区分大小写的变体为 〜*
。
分支包含在()
中。
The regular expression match operator in Postgres is ~
.
The case insensitive variant is ~*
.
Branches are enclosed in ()
.
SELECT text
FROM eightks
WHERE other_events = true
AND keywordregexs ~* '(\y(director | member \s+ |resigned)\y)';
在问题中不清楚那些精确短语的含义。
< a href = http://www.postgresql.org/docs/current/interactive/functions-matching.html#FUNCTIONS-POSIX -REGEXP rel = nofollow>手册中的详细信息。
The meaning of "those exact phrases" is not clear in the question.
Details in the manual.
这篇关于正则表达式和文本匹配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文