使用 'regexp' 的相同查询在 mysql 中给出不同的结果
same queries using 'regexp' gives different result in mysql
基本上,我想要的是理解为什么
select 'aa' regexp '[h]'
returns 0 和
select 'აა' regexp '[ჰ]'
returns 1 ?
检查FIDDLE
我认为 MySQL regex 还不支持 utf-8。参见 bug 30241 and 12.5.2 Regular Expressions。
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.
你可以匹配没有字符的字节序列 class: SELECT 'აა' REGEXP 'ჰ'
returns 0
.
基本上,我想要的是理解为什么
select 'aa' regexp '[h]'
returns 0 和
select 'აა' regexp '[ჰ]'
returns 1 ?
检查FIDDLE
我认为 MySQL regex 还不支持 utf-8。参见 bug 30241 and 12.5.2 Regular Expressions。
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.
你可以匹配没有字符的字节序列 class: SELECT 'აა' REGEXP 'ჰ'
returns 0
.