为什么用[\u4e00-\u9fa5]匹配的是非中文?

时间:2022-01-06 21:19:21
mysql> select '中文' regexp '[\u4e00-\u9fa5]';
+---------------------------------+
| '中文' regexp '[\u4e00-\u9fa5]' |
+---------------------------------+
|                               0 |
+---------------------------------+
1 row in set (0.00 sec)

mysql> select 'zw' regexp '[\u4e00-\u9fa5]';
+-------------------------------+
| 'zw' regexp '[\u4e00-\u9fa5]' |
+-------------------------------+
|                             1 |
+-------------------------------+
1 row in set (0.00 sec)


mysql> select '中文' not regexp  '[\u4e00-\u9fa5]';
+--------------------------------------+
| '中文' not regexp  '[\u4e00-\u9fa5]' |
+--------------------------------------+
|                                    1 |
+--------------------------------------+
1 row in set (0.00 sec)


为什么跟我理解的正好相反??

6 个解决方案

#1


检查一下字符集设置。

#2


引用 1 楼 ACMAIN_CHM 的回复:
检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?

#3


引用 2 楼 yangfanzn 的回复:
Quote: 引用 1 楼 ACMAIN_CHM 的回复:

检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?
显然不是UTF8

#4


引用 3 楼 ACMAIN_CHM 的回复:
Quote: 引用 2 楼 yangfanzn 的回复:

Quote: 引用 1 楼 ACMAIN_CHM 的回复:

检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?
显然不是UTF8


为什么用[\u4e00-\u9fa5]匹配的是非中文?
整理那里不是 utf8-bin么?这不算是utf8格式么?

#5


什么原因呀,求关注呀

#6


问题解决了,不是什么字符集设置的问题的
具体看下面的连接
http://bbs.csdn.net/topics/390111997

#1


检查一下字符集设置。

#2


引用 1 楼 ACMAIN_CHM 的回复:
检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?

#3


引用 2 楼 yangfanzn 的回复:
Quote: 引用 1 楼 ACMAIN_CHM 的回复:

检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?
显然不是UTF8

#4


引用 3 楼 ACMAIN_CHM 的回复:
Quote: 引用 2 楼 yangfanzn 的回复:

Quote: 引用 1 楼 ACMAIN_CHM 的回复:

检查一下字符集设置。

+--------------------------+-----------------------------------------------+
| Variable_name            | Value                                         |
+--------------------------+-----------------------------------------------+
| character_set_client     | gbk                                           |
| character_set_connection | gbk                                           |
| character_set_database   | latin1                                        |
| character_set_filesystem | binary                                        |
| character_set_results    | gbk                                           |
| character_set_server     | latin1                                        |
| character_set_system     | utf8                                          |
| character_sets_dir       | e:\wamp\bin\mysql\mysql5.5.20\share\charsets\ |
+--------------------------+-----------------------------------------------+

数据库用的是utf8

请问应该怎么设置呢?
显然不是UTF8


为什么用[\u4e00-\u9fa5]匹配的是非中文?
整理那里不是 utf8-bin么?这不算是utf8格式么?

#5


什么原因呀,求关注呀

#6


问题解决了,不是什么字符集设置的问题的
具体看下面的连接
http://bbs.csdn.net/topics/390111997