glwtta has asked for the wisdom of the Perl Monks concerning the following question:
I have a very silly problem: I am displaying the results of a search, I have the string searched for and the result string, what I need to do is highlight the query string in the results, but also to put a line break in the result every 80 characters.
So, if I do the breaks I can no longer match the query within the results (since it could have a \n in it) and if I do the markup first, a \n could fall within the 'span' tag.
What I do right now is save the original start index of the query string, insert the breaks, then calculate the number of breaks that would go before it and insert the tags accordingly. Somehow this just doesn't feel very elegant, is there a more perly way?
thanks a lot
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: highlight and line breaks
by Aristotle (Chancellor) on Jan 16, 2003 at 00:29 UTC | |
|
Re: highlight and line breaks
by sauoq (Abbot) on Jan 16, 2003 at 00:58 UTC | |
by glwtta (Hermit) on Jan 16, 2003 at 01:21 UTC | |
by sauoq (Abbot) on Jan 16, 2003 at 02:24 UTC | |
by Aristotle (Chancellor) on Jan 16, 2003 at 09:12 UTC | |
by bbfu (Curate) on Jan 16, 2003 at 07:30 UTC | |
by sauoq (Abbot) on Jan 16, 2003 at 08:42 UTC | |
| |
|
Re: highlight and line breaks
by chromatic (Archbishop) on Jan 15, 2003 at 22:44 UTC |