MySQL Regexp是否支持Unicode匹配 [英] Does MySQL Regexp support Unicode matching

查看:263
本文介绍了MySQL Regexp是否支持Unicode匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道Mysql的regexp是否支持unicode吗?我一直在做一些研究,大多数博客等都表明存在问题或不支持该问题.我想知道,最好将LIKE用于unicode模式匹配,将regexp用于ASCII增强模式匹配吗?

我喜欢能够在字符串开头或结尾搜索匹配项的想法,但是如果regexp不支持unicode,那么如果我的文本是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. I'm wondering then is it best to use LIKE for unicode pattern matching and regexp for ASCII enhanced pattern matching?

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.

推荐答案

有人知道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.

正则表达式中所述:

警告

REGEXP

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'
    

  • 这篇关于MySQL Regexp是否支持Unicode匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆