Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regexp - How to find capital letters in MySQL only

Tags:

regex

mysql

I'am trying to delete words which have 2 capital letters consecutively with MySQL. Like: "ABC", "AA", "NBC". No others.

The following query doesn't work (it finds all words, which have 2 letters)

  WHERE names REGEXP '[A-Z][A-Z]'

Do you know how to do that?

like image 992
Crayl Avatar asked Dec 29 '11 10:12

Crayl


2 Answers

WHERE names REGEXP BINARY '[A-Z]{2}'

REGEXP is not case sensitive, except when used with binary strings.

http://dev.mysql.com/doc/refman/5.5/en/regexp.html

like image 123
zerkms Avatar answered Oct 22 '22 03:10

zerkms


This pattern matches two or more leading uppercase characters:

WHERE names REGEXP BINARY '^[A-Z]{2,}';
like image 37
Martin Zeitler Avatar answered Oct 22 '22 01:10

Martin Zeitler