3

The mySql REGEXP operator is not case sensitive. Is there a version of this operator that is case sensitive?

2
  • that is what documentation says but if you take a look bit further i.e. dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp the example 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. Commented Apr 25, 2012 at 12:44
  • I think this depends on your storage engine, InnoDB, MyISAM etc. Have you tried it on different types? Commented Apr 25, 2012 at 12:45

1 Answer 1

5

Use the BINARY keyword, which forces REGEXP to match the string as a binary string, which is done case-sensitively.

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

Although this isn't explicitly stated in the docs (that you can do it with a regular string), in my experience it works as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.