Bug #53474 Regular expression word boundary at end of string
Submitted: 7 May 2010 5:42 Modified: 7 May 2010 5:59
Reporter: Daniel DeLorme Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.46, 5.1.36 OS:Any (FreeBSD, Windows XP)
Assigned to: CPU Architecture:Any
Tags: REGEXP

[7 May 2010 5:42] Daniel DeLorme
Description:
Regular expression query returns invalid result when a end-of-word marker is followed by a end-of-string marker.

SELECT 'bug' REGEXP 'bug[[:>:]]$';

should return 1 but returns 0.

How to repeat:
SELECT 'bug' REGEXP 'bug[[:>:]]$';
[7 May 2010 5:59] Valeriy Kravchuk
Thank you for the problem report. Verified just as described:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -proot -P3310 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.1.46-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT 'bug' REGEXP 'bug[[:>:]]$';
+----------------------------+
| 'bug' REGEXP 'bug[[:>:]]$' |
+----------------------------+
|                          0 |
+----------------------------+
1 row in set (0.05 sec)

mysql> SELECT 'bug' REGEXP 'bug[[:>:]]';
+---------------------------+
| 'bug' REGEXP 'bug[[:>:]]' |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.02 sec)

mysql> SELECT 'bug' REGEXP 'bug$';
+---------------------+
| 'bug' REGEXP 'bug$' |
+---------------------+
|                   1 |
+---------------------+
1 row in set (0.00 sec)