PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 14th, 2002, 12:12 PM
johnn johnn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Westminster, CA USA
Posts: 54 johnn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 12 m 7 sec
Reputation Power: 8
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

Reply With Quote
  #2  
Old March 14th, 2002, 02:29 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
Quote:
I would like to REGEXP in mysql to see if user enter any word matching keyword list

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.

Reply With Quote
  #3  
Old March 14th, 2002, 03:32 PM
johnn johnn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Westminster, CA USA
Posts: 54 johnn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 12 m 7 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old March 14th, 2002, 04:34 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 185
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...)

Reply With Quote
  #5  
Old March 15th, 2002, 03:21 PM
johnn johnn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Westminster, CA USA
Posts: 54 johnn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 12 m 7 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Regexp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT