MySQL RegEx Matching

admin

Administrator
Staff member
Hi,

I have a list of words in a MySQL database, and I'd like to find ones that match the query like this:

asodgf would match dog
dog would match dog
god would match dog

but:

dog would not match dogs
do would not match dog


I've tried using:

SELECT word FROM words WHERE word RLIKE '(.*)$query(.*)'

but of course that doesn't match backwards etc...

I've been searching for several hours. Any help would be appreciated!
-Chris
 
Back
Top