This one is killing me,i’m a total noob with regex.
Im trying to make a site search and compare the entered text with the titles column in the
database.
Basically what i want to accomplish with regex is LIKE ‘%word1 word2 word3%’ , but with some string variatons.
For example :
SELECT * FROM table WHERE title REGEXP
‘w[ao]rd’
works just fine. It looks for word and ward. But when i want multiple words it returns nothing.
SELECT * FROM table WHERE title REGEXP
‘w[ao]rd sec[or]nd th[io]rd’
I don’t want to search for word OR second OR third i want to have them all in the title,just like in the upper case with LIKE.
I was thinking maybe to explode the search string the user inputs then in a foreach do a regexp word by word,but don’t know how to concatenate all of the variations into one query.
EDIT:
I forgot to mention that im searching in a utf8_unicode_ci collated table.
So really im trying to do a [cčć]orak type of search.
edit:
“okay so you want them to all be in the title and in that order?”
This will look for those words (and the variations) and make them be in that order, so for example