REGEXP for search engine/SQL Server
| From: | Kevin Won | Date: | Tue, 21 May 2002 18:32:36 +0000 |
| Subject: | REGEXP for search engine/SQL Server | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-19334@lists.php.net to get a copy of this message | ||
I'm having a bit of difficulty getting my REGEXP right for my search engine. I'm hoping
someone has done this already--it is actually a rather simple problem but I suck at regexps . . .
problem: need to concatinate a query string with like '%searchterm%' from a list of words
from a webform, but also need to identify "quoted terms" which should not have wildcards
infront/behind them.
so the result for a search query of
this is "my search" term set
should end up:
SELECT * FROM TABLE WHERE keywords LIKE '%this%'
OR keywords LIKE '%is%'
OR keywords LIKE 'my search'
OR keywords LIKE '%term%'
OR keywords LIKE '%set%'
so the quoted term doesn't have the wildcards in front/behind.
I'm using preg_split to cut the words using a \s space character presently--I haven't yet
implemented containing "quoted terms". I'm unsure how to keep the "quoted
terms" together yet split the other words apart.
I'm guessing someone has done this on the list. ..
thanks
Kevin Won
-------------------------------------------------------------
ITG Web Developer,
Systems Administrator
Oregon Health Sciences University
(503) 418-4282
cell: (503) 913-5367
page: x15897
fax: (503) 494-1888