Forum Moderators: phranque

Message Too Old, No Replies

bold the text found

         

charonlee

1:07 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



hi,
I really can't think of how could I replace whatever text which found with <b> (bold). Please don't misundertand what I want, below is the explaination.

strSearch = "Data"

Once the text is found (case insensitive), "bold" it.
For instance, the text that I'm going to match is "Data",

1.) if the first content has "data" just bold it data , not
Data

2.) If the content has "DATA", just bold DATA , not
Data

Please advice, thanks. Currently I only manage to replace whatever text found with the strSearch. As long as there has "Data" matched, it will bold it with "Data", but this is not what i want.

andreasfriedrich

1:24 pm on Mar 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




$text =~ s [perldoc.com]!(data)!<b>$1</b>!i;
$text = preg_replace [php.net]("'(data)'i", "<b>\\1</b>", $text);

will do the job in either Perl [perl.com] or PHP [php.net].

Andreas