...

View Full Version : regex, invalid character range '\'



BubikolRamios
10-07-2011, 01:57 PM
OK


select '(NH4)SO4' REGEXP '^[A-Z0-9=\-]+$'


Invalid character range


select '(NH4)SO4' REGEXP '^[A-Z0-9=\-()]+$'
select '(NH4)SO4' REGEXP '^[A-Z0-9=\-\(\)]+$'


How to solve that ?

Old Pedant
10-08-2011, 07:50 AM
MySQL is stupid.

It doesn't allow the - in a [...] set of characters *EXCEPT* as the last character in the set.



select '(NH4)SO4' REGEXP '^[A-Z0-9=\(\)\-]+$'

works fine.

But so does simply


select '(NH4)SO4' REGEXP '^[A-Z0-9=()-]+$'

In other words, the \- and - are seen as the same thing in that context.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum