----- Original Message ----- From: "Deniz Dizman (BST UGB)" <[EMAIL PROTECTED]> To: "C.R.Vegelin" <[EMAIL PROTECTED]>; "[EMAIL PROTECTED]" <php-general@lists.php.net>
Sent: Thursday, September 20, 2007 10:38 AM
Subject: RE: [PHP] highlighting searchterms as bold text


try /^ethyl/i
what you want is ignore case and pattern begins with

--
dd

-----Original Message-----
From: C.R.Vegelin [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 20, 2007 1:31 PM
To: [EMAIL PROTECTED]
Subject: [PHP] highlighting searchterms as bold text

Hi everyone,

I want to highlight (bold) searchterms in text.
For example, for all words starting with "ethyl":
a) replace "ethyl" by "<b>ethyl</b>"
b) replace "Ethyl" by "<b>Ethyl</b>"
c) replace "ethylene" by "<b>ethylene</b>"
d) but not "methyl" by "<b>methyl</b>"

Now I use:
$patterns[0] = "/ethyl/";
$replacements[0] = "<b>ethyl</b>";
$text = preg_replace($patterns, $replacements, $text);

This works for a) and c), but not for b) and d).
Any idea how to do this ?

TIA, Cor


Thanks Deniz,

I tried pattern /^ethyl/i but this does not highlight anything.
I also tried pattern /ethyl/i and this highlights all, but also methyl ...
Any suggestion ?

Cor

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to