Highlighting words in text

If I have a string: @tmp = “This is a test string 1 2 3 testing…”
and I want to higlight a string “test” when I show it on a page, so how
I can do it?

Result shold be like this: “This is a test string 1 2 3
testing”

<%= highlight “your text”, [“test”], “\1” %>

See the ActionView::Helpers::TextHelper#highlight method. :slight_smile:

–Jeremy

On Jan 5, 2008 12:23 PM, Gi Ga [email protected] wrote:


http://www.jeremymcanally.com/

My books:
Ruby in Practice

My free Ruby e-book
http://www.humblelittlerubybook.com/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/

Jeremy McAnally wrote:

See the ActionView::Helpers::TextHelper#highlight method. :slight_smile:

Sorry :slight_smile: Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs