且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL Regexp 是否支持 Unicode 匹配

更新时间:2022-03-21 23:29:51

有谁知道Mysql的regexp是否支持unicode?我一直在做一些研究,大多数博客等似乎都表明存在问题或不支持.

Does anyone know if Mysql's regexp supports unicode? I've been doing some research and the majority of blogs etc. seem to indicate that there is a problem or its not supported.

正则表达式所述:

REGEXPRLIKE 运算符以字节方式工作,因此它们不是多字节安全的,可能会使用多字节字符集产生意外结果.此外,这些运算符按字节值比较字符,即使给定的排序规则将它们视为相等,重音字符也可能不相等.

Warning

The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multi-byte safe and may produce unexpected results with multi-byte 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.

  • 我想知道***使用 LIKE 进行 unicode 模式匹配,使用 regexp 进行 ASCII 增强模式匹配吗?

    I'm wondering then is it best to use LIKE for unicode pattern matching and regexp for ASCII enhanced pattern matching?

    是的,那***.

    我喜欢能够在字符串的开头或结尾搜索匹配项的想法,但如果 regexp 不支持 unicode,那么如果我的文本是 unicode,这可能会很困难.

    I Like the idea of being able to search for matches at the beginning or end of a string, but if regexp doesn't support unicode then this could be difficult if my text is unicode.

    也可以使用 LIKE 做到这一点:

    One can do that with LIKE too:

    WHERE foo LIKE 'bar%'
    

    还有:

    WHERE foo LIKE '%bar'