Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Note, the output is ALMOST perfect: "this is the test text for this - 2" routine. The output I want is: "This is the test text for THIS - 2" routine. As you can see the text is changed to the searchstring, thus the original caps information is modified. I need to find a way to make the match occur and replace the matched text with itself & the bold tags. Any ideas for an elegant solution, I am not that good yet with the matching functions in perl, thus I need a little help.#START CODELET $Data = "This is the test text for THIS routine."; $SearchString = "this"; $BoldStart = "<b>"; $BoldEnd = "</b>"; $CountNum -= ($Data =~ s/$searchstring/$BoldStart$searchstring$BoldEnd +/gi); print "$Data - $CountNum\n"; exit; #END CODELET
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching problems
by dws (Chancellor) on Apr 20, 2002 at 00:04 UTC | |
by Kanji (Parson) on Apr 20, 2002 at 00:17 UTC | |
by Anonymous Monk on Apr 20, 2002 at 04:22 UTC | |
|
Re: Matching problems
by belg4mit (Prior) on Apr 20, 2002 at 00:05 UTC | |
|
Re: Matching problems
by Fletch (Bishop) on Apr 20, 2002 at 00:03 UTC |