【问题标题】:MySql REGEXP operatorMySql REGEXP 运算符
【发布时间】:2012-04-25 12:41:10
【问题描述】:

mySql REGEXP 运算符不区分大小写。此运算符是否有区分大小写的版本?

【问题讨论】:

  • 这就是文档所说的,但如果您进一步看一下,即dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp 示例As a more complex example, the regular expression B[an]*s matches any of the strings Bananas, Baaaaas, Bs, and any other string starting with a B, ending with an s, and containing any number of a or n characters in between.
  • 我认为这取决于您的存储引擎、InnoDB、MyISAM 等。您是否在不同类型上尝试过?

标签: mysql regex operators


【解决方案1】:

使用BINARY 关键字,强制REGEXP 将字符串匹配为二进制字符串,这是区分大小写的。

SELECT 'a' REGEXP 'A', 'a' REGEXP BINARY 'A';

虽然这不是明确的stated in the docs(您可以使用常规字符串执行此操作),但根据我的经验,它可以按预期工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-27
    • 2015-05-23
    • 2011-11-25
    • 2013-09-28
    • 2014-04-22
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多