PDA

View Full Version : REGEXP matching string for searching


coffeedemon
01-01-2004, 12:26 AM
i'm trying to make a search engine that will search a string for $q i have now:

SELECT title FROM table WHERE title REGEXP '($_GET[q])+' "

the problem with REGEXP '($_GET[q])+' is it searches the entire frase only. like if someone searched for "this that and more" it will not match a string with just "this" or "that and" it will only match a sring with the entire "this that and more".

how do i make it so it will match each word as well as the entire string?

raf
01-01-2004, 09:57 PM
Why use regex for that?

Why not run a fulltext search, which is created exactly for this.

coffeedemon
01-02-2004, 10:03 PM
probably because i didn't know it existed.

raf
01-03-2004, 01:49 AM
Originally posted by coffeedemon
probably because i didn't know it existed.
I suppose thats a very good reson.

But regex realy are only the best sollution if your searching for/checking for a pattern or valueformat. If you are looking for an actual value, then there will probably always be a more efficient method, as in your situation.

coffeedemon
01-05-2004, 01:45 AM
thanks much.