On Thu, 06 Dec 2001 14:06:16 +0100, Ralph F. wrote:
>the searchcriteria in the searchform is:
>FOL
>
>at the moment my engine delivers the following back to the searchers
>browser:
>
>Hi <b>FOL</b>ks.
>
>But it shall deliver:
>Hi <b>fol</b>ks.
Code please? ;-)
I suspect that currently you're using something like
s/$search/<b>$search<\/b>/gi;
and you can replace that with
s/($search)/<b>$1<\/b>gi;
Actually, the above is quite unsafe WRT tainting, because you have no
control to what people enter. They can enter any regex, if it's not a
valid regex, this code will die. quotemeta() can prevent that, allowing
only literal searches:
s/(\Q$search\E)/<b>$1<\/b>/gi;
'\Q' is the inside-a-double-quotish-string drop-in replacement for the
quotemeta() function.
--
Bart.