librarygeek has asked for the wisdom of the Perl Monks concerning the following question:
The function seems at first to work perfectly, then I noticed a flaw. If the variable "$searchstring" contains "Foo" and the $texttosearch contains "foo" the search will highlight the text as it should but, because of the way it is written "Foo" now becomes "foo". I need to be able to retain the case of the original text while still being able to search and highlight irregardless of case. I thank you in advance for your help.sub HighlightText { my ($texttosearch,$searchstring,$color)=@_; my $highlighted = "<FONT COLOR='$color'><B>$searchstring</B></FONT> +"; $texttosearch =~ s/$searchstring/$highlighted/gi; return $texttosearch; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Search Term Highlighting
by sean (Beadle) on Jun 14, 2000 at 19:11 UTC | |
by librarygeek (Novice) on Jun 14, 2000 at 20:16 UTC | |
|
RE: Search Term Highlighting
by muppetBoy (Pilgrim) on Jun 14, 2000 at 18:46 UTC | |
by librarygeek (Novice) on Jun 15, 2000 at 02:23 UTC | |
|
Re: Search Term Highlighting
by gnat (Beadle) on Jun 14, 2000 at 22:35 UTC | |
|
RE: Search Term Highlighting
by Anonymous Monk on Jun 15, 2000 at 02:09 UTC | |
by chromatic (Archbishop) on Jun 15, 2000 at 02:19 UTC | |
by librarygeek (Novice) on Jun 15, 2000 at 02:27 UTC |