Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Regexp用于搜索包含某些特定单词的记录_Mysql_Regex - Fatal编程技术网

Mysql Regexp用于搜索包含某些特定单词的记录

Mysql Regexp用于搜索包含某些特定单词的记录,mysql,regex,Mysql,Regex,我想使用mysql选择所有记录都只有 上面写着: 4ahhyes4,4ahh4,4AHA4、空白和点。 这是我的问题 SELECT * FROM p_posts WHERE post_content REGEXP '^(4ahhyes4|4ahh4|4ahaa4|\.|\s)+$'; 但它将所有记录与其他字符匹配(就像语法一样): 如何仅匹配包含这些单词的记录?其中('4ahhyes4','4ahh4','4AHA4','whitespace and dot')中的post\u内容不符合操作员

我想使用mysql选择所有记录都只有

上面写着:

4ahhyes4,4ahh4,4AHA4、空白和点。

这是我的问题

SELECT * FROM p_posts WHERE post_content REGEXP '^(4ahhyes4|4ahh4|4ahaa4|\.|\s)+$';
但它将所有记录与其他字符匹配(就像语法一样):


如何仅匹配包含这些单词的记录?

其中('4ahhyes4','4ahh4','4AHA4','whitespace and dot')中的post\u内容不符合操作员定义中的要求?

注意
因为MySQL在字符串中使用C转义语法(例如,“
\n
”来表示换行符),所以必须将字符串中使用的任何“
\
”加倍

有关的文件说明:

MySQL识别中所示的转义序列。对于所有其他转义序列,将忽略反斜杠。也就是说,转义字符被解释为未转义。例如,“
\x
”只是“
x

因此,当前匹配的模式是
^(4ahhyes4 | 4ahh4 | 4aha4 | s)+$
。你应该改为:

SELECT *
FROM   p_posts
WHERE  post_content REGEXP '^(4ahhyes4|4ahh4|4ahaa4|\\.|\\s)+$'

tks。以下是我完整的语法:^(4ahhyes4 | 4ahh4 | 4aha4 | \.[[:space:]])+$\\s似乎不能与mysql一起使用?
SELECT *
FROM   p_posts
WHERE  post_content REGEXP '^(4ahhyes4|4ahh4|4ahaa4|\\.|\\s)+$'