gpt4 book ai didi

mysql - MySQL Regexp 是否支持 Unicode 匹配

转载 作者:行者123 更新时间:2023-11-29 18:55:04 26 4
gpt4 key购买 nike

有谁知道Mysql的正则表达式是否支持unicode?我一直在做一些研究,大多数博客等似乎都表明存在问题或不受支持。我想知道最好使用 LIKE 进行 unicode 模式匹配,使用 regexp 进行 ASCII 增强模式匹配吗?

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

最佳答案

  1. 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.

    Regular Expressions 下所述:

    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.

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

    是的,那就最好了。

  3. 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 来做到这一点:

    WHERE foo LIKE 'bar%'

    还有:

    WHERE foo LIKE '%bar'

关于mysql - MySQL Regexp 是否支持 Unicode 匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44190453/

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