Re: REGEXP for search engine/SQL Server
| From: | Benjamin Walling | Date: | Tue, 21 May 2002 19:16:35 +0000 |
| Subject: | Re: REGEXP for search engine/SQL Server | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19335@lists.php.net to get a copy of this message | ||
Why not yank the quoted terms out before using split? Search for patterns
".*" and put them in a separate array. Once those are gone, split the
remaining string. You may want to remove duplicate spaces created by
removing the quoted terms.
"Kevin Won" <wonk@ohsu.edu> wrote in message
news:scea3062.060@gwsmtp.ohsu.edu...
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