gpt4 book ai didi

MySQL Regexp 点(任意)不匹配重音字符

转载 作者:行者123 更新时间:2023-11-29 06:33:35 26 4
gpt4 key购买 nike

根据documentation . 应匹配任何字符,但不匹配重音字符。

mysql> select 'test' regexp 't.st';
+----------------------+
| 'test' regexp 't.st' |
+----------------------+
| 1 |
+----------------------+
1 row in set (0.00 sec)

mysql> select 'tést' regexp 't.st';
+-----------------------+
| 'tést' regexp 't.st' |
+-----------------------+
| 0 |
+-----------------------+

我是不是做错了什么,或者无论如何都可以匹配任何字符,包括特殊/重音字符?

我的数据库排序规则是 utf8_general_ci,我在测试查询上使用 collat​​e 命令尝试了一些不同的排序规则,但没有成功。

最佳答案

遵循 MySQL 文档:

Warning

The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multibyte safe and may produce unexpected results with multibyte character sets. In addition, these operators compare characters by their byte values and accented characters may not compare as equal even if a given collation treats them as equal.

所以你不应该这样做。

来源:http://dev.mysql.com/doc/refman/5.0/en/regexp.html

关于MySQL Regexp 点(任意)不匹配重音字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26388166/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com