DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Benoit has posted 48 posts at DZone. View Full User Profile

Regular Expressions With MySQL

01.19.2008
| 4937 views |
  • submit to reddit
        
SELECT * FROM texts WHERE content REGEXP '[^a-z]Hello[^a-z]' ;

If you really want to force a REGEXP comparison to be case sensitive, use the BINARY keyword to make one of the strings a binary string.
SELECT * FROM texts WHERE content REGEXP BINARY '[^a-zA-Z]Hello[^a-zA-Z]' ;

Warning: some characters do not work. Example :
SELECT * FROM texts WHERE content REGEXP '[^\w]Hello[^\w]' ;

<a href="http://www.ab-d.fr/">ab-d.fr source code</a>