|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Regexp
Say I have a list of 3 key words: 'mi go home'.
Then user enters into a search such as 'm go home' that I will assemble them into a regexp such as [(m)(go)(home)] I would like to REGEXP in mysql to see if user enter any word matching keyword list by select ... searchwordField REGEXP '[(m)(go)(home)]'; 'go' and 'home' match, but 'm' should not 'mi', but it did. How to use REGEXP correctly? Thanks in advance, John |
|
#2
|
|||
|
|||
|
Quote:
this is not what regexps are for. use the SQL command "IN" or "LIKE" for the first: make php split() your search string and then it is "WHERE ... IN ($word1,$word2,$word3)" for the last one: "WHERE ... LIKE 'm%go%home' ") regexps (if i understood your question correctly and can make it up without the manual without errors) would be: "(m|go|home)" or something similar... sorry, too lazy to look it up. rtfm yourself.
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
I have doubt about that too, but in an article about search engine, John Coggeshall used it:
http://www.zend.com/zend/spotlight/...hengine2may.php Why? I'm unable to make it work. |
|
#4
|
|||
|
|||
|
maybe he is far beyond my knowledge. maybe heīs making mistakes just like everybody else is too.
try it the way i told you. do you have any results? (probably you need to test any way that is possible - not much since it is only three keywords: 2^3=8 possibilities - easy proof, ainīt it?) does it work? maybe John referred to different conditions.. maybe i am totally wrong ![]() (100% that i had too much alc already... plz replx to tis post so i can look at it again tomorrow when i am clear-minded...) |
|
#5
|
|||
|
|||
|
I use this
"WHERE ... IN ($word1,$word2,$word3)" I couldn't use regexp. I have doubt if Coggeshall test his code. His codes in other articles are quite buggy too. Thanks, John |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Regexp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|