"Christian Borchgrevink-Lund" <borchgrevink@yahoo.com> skrev:
> I want to such match "foo" in "foo bar", "bar foo", "bar foo
> bar", or "foo" but not in "foobar" or "barfoo". I try this
> query:
> "SELECT * FROM forumPosts WHERE (message LIKE
> '(^|[^a-zA-Z])$sokSplitt[$i]([^a-zA-Z]|$)')"
I am not sure how your database implements regex, but I doubt that
(^|[<pattern>]) will work. If \b (word boundary) is supported, you
should be able to use LIKE '\b$sokSplitt[$i]\b' - that's it.
Without regex'es you can do something like:
WHERE (' ' + message + ' ') LIKE '% $sokSplitt[$i] %'
It will match "foo" in "foo", "foo bar", "bar foo", and not match
"foobar" or "barfoo". However, it will also not match foo in
"foo.", "foo, bar", "foo!" etc.
Hope it helps.
--
Jens Gyldenkærne Clausen
MF (Medlem af Fiduso -
www.fiduso.dk)