| Bug #50790 | Bug in RegExp | ||
|---|---|---|---|
| Submitted: | 1 Feb 2010 12:44 | Modified: | 1 Feb 2010 17:02 |
| Reporter: | Petr Valkoun | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
| Version: | 5.0.83 and 5.1.42 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | REGEXP | ||
[1 Feb 2010 15:18]
Giuseppe Maxia
Thanks for reporting, but this is nor a bug. The regular expressions used by MySQL are not the same used by Perl/PHP/Python. http://dev.mysql.com/doc/refman/5.1/en/regexp.html Your query should use the :alpha: or :alnum: character classes select 'airbag: 2 kopf- ' regexp '^[[:alpha:]]*:'; +--------------------------------------------+ | 'airbag: 2 kopf- ' regexp '^[[:alpha:]]*:' | +--------------------------------------------+ | 1 | +--------------------------------------------+
[1 Feb 2010 17:02]
Petr Valkoun
ok, thanks for expalining, I was confused because '^\\w*' worked, but now I tried it with '^\\w' and it doesnt and now I see why...sorry for tour time

Description: Hello, this query returns false, while www.myregexp.com returns true: mysql> select 'airbag: 2 kopf- ' regexp '^\\w*:' -> ; +------------------------------------+ | 'airbag: 2 kopf- ' regexp '^\\w*:' | +------------------------------------+ | 0 | +------------------------------------+ 1 row in set (0.00 sec) Even worse, this also doesnt work: mysql> select 'airbag: 2 kopf- ' regexp '^\\w+'; +-----------------------------------+ | 'airbag: 2 kopf- ' regexp '^\\w+' | +-----------------------------------+ | 0 | +-----------------------------------+ while the same query with * instead of + works. Interesting iss the original query works without ':' or '^', but not with both of them. Is this a feature or a bug? Thanks for your efford for crating best free database on earth! How to repeat: run this query in any latest 5.0 or 5.1 mysql server: select 'airbag: 2 kopf- ' regexp '^\\w*:'