Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting RegEx Match  RSS feed

 
Mike London
Ranch Hand
Posts: 1391
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In MySQL, the following says it's true:

select 'city' regexp '^[A-Z]+'


(Result: 1)

==

Yet, in every other SQL tool I've tried, it's the expected result: zero (false).

How do I get MySQL to get this right or am I missing something?

Thanks in advance,

-- mike
 
Knute Snortum
Sheriff
Posts: 3715
90
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From https://dev.mysql.com/doc/refman/5.7/en/regexp.html

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

mysql> SELECT 'Michael!' REGEXP '.*';
        -> 1
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
        -> 1
mysql> SELECT 'a' REGEXP 'A', 'a' REGEXP BINARY 'A';
        -> 1  0
mysql> SELECT 'a' REGEXP '^[a-d]';
        -> 1
 
Mike London
Ranch Hand
Posts: 1391
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:From https://dev.mysql.com/doc/refman/5.7/en/regexp.html

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

mysql> SELECT 'Michael!' REGEXP '.*';
        -> 1
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
        -> 1
mysql> SELECT 'a' REGEXP 'A', 'a' REGEXP BINARY 'A';
        -> 1  0
mysql> SELECT 'a' REGEXP '^[a-d]';
        -> 1


Knute,

I had just found the BINARY option and was headed back here to update my posting.

Appreciate very much your reply.

Thanks!

- mike
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!