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 匹配连字符词_Mysql_Regex_Mariadb - Fatal编程技术网

Mysql 匹配连字符词

Mysql 匹配连字符词,mysql,regex,mariadb,Mysql,Regex,Mariadb,我正在尝试选择在某个列中具有连字符的所有行。这就是我到目前为止所做的: SELECT * FROM MyTable WHERE list RLIKE '\w-\w' 但当我知道还有很多的时候,它只返回了1排。你知道为什么吗 多谢各位 | List | built-in self-discipline hang-up .... 编辑:不确定这是否重要,但列表是utf8\U unicode\U ciMySQL正则表达式不支持\w(或字符类的任何其他转义序列)。你必须写: SELECT * FRO

我正在尝试选择在某个列中具有连字符的所有行。这就是我到目前为止所做的:

SELECT * FROM MyTable WHERE list RLIKE '\w-\w'
但当我知道还有很多的时候,它只返回了1排。你知道为什么吗

多谢各位

| List |
built-in
self-discipline
hang-up
....

编辑:不确定这是否重要,但列表是utf8\U unicode\U ci

MySQL正则表达式不支持
\w
(或字符类的任何其他转义序列)。你必须写:

SELECT * FROM MyTable WHERE list RLIKE '[[:alnum:]_]-[[:alnum:]_]'

有关MySQL正则表达式的详细信息,请参阅。

如果要尝试在不使用正则表达式的情况下使用它,请尝试使用通配符。。不确定你是否不能使用它,但这也应该有效

SELECT * FROM MyTable WHERE list LIKE '%-%'

它在数据库中是什么样子?@JohnRuddell你是什么意思?实际字符串是什么样子?@JohnRuddell请查看我的编辑说明为什么使用regex?为什么不干脆用“%-%”之类的
位置列表呢?谢谢。不知道它不支持\w。在发布到SO之前,是否有人检查文档?