tags:

views:

79

answers:

3

When I search the db for a certain value, say a singular noun like "party", I want to be able to get the value "party" from the db, even though it's actually "parties". For that I thought about replacing the -ies suffix for -y, which didn't have any conspicuous exceptions (maybe "lies").

Is there a MySQL equivalent to the PHP Preg_Replace using regex? Can I handle it otherwise without a mysql function?

so:

SELECT * 
  FROM table 
 WHERE preg_replace('/(.)*ies/','y',column) 
 WHERE column="party";'

Thanks!

+1  A: 

Please see this question: http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql

Kamil Szot
The lone answer there is interesting. It links to a set of user defined functions, including one that does a regex replace: launchpad.net/mysql-udf-regexp
Ewan Todd
A: 

Take a look at this:

http://dev.mysql.com/doc/refman/5.1/en/regexp.html

koen
A: 

Theres a replace function which uses regular expressions

Ben Shelock