Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Search Term Highlighting

by gnat (Beadle)
on Jun 14, 2000 at 22:35 UTC ( [id://18156]=note: print w/replies, xml ) Need Help??


in reply to Search Term Highlighting

If you have an array of search terms, you can highlight any one of them with:
$re = join "|", map {quotemeta} @term;
$results = s{($re)}{$1}ig;
That's just a simple extension of sean's code. If your search terms are regexps and not plain strings, then do without the mapping of quotemeta.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://18156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-16 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found