# Highlight (ActionView::Helpers::TextHelper)

**URL:** <https://www.ruby-forum.com/t/highlight-actionview-texthelper/67572>\
**Category:** Ruby\
**Created:** [September 5, 2006, 10:47am UTC](https://www.ruby-forum.com/t/highlight-actionview-texthelper/67572 "2006-09-05T10:47:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 5, 2006, 10:47am UTC](https://www.ruby-forum.com/t/highlight-actionview-texthelper/67572/1 "2006-09-05T10:47:44Z")

</div>

I’m using that helper function with a search form to highlight the  
typed phrase in the content BUT when my content is HTML, I’ll get  
replacement where I don’t want to.

For instance :

@page.content = “

My text containing AJAX

”

What I get :  
highlight (@page.content, ‘ajax’)

=\>

![<span
class="highlight">Ajax</span> Image]()My text containing ajax

What I want to get :  
highlight (@page.content, ‘ajax’)

=\>

My text containing ajax

Don’t know much to RegExp, is this possible to do ?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 5, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/highlight-actionview-texthelper/67572/2 "2006-09-05T18:32:03Z")

</div>

On Sep 5, 2006, at 1:45 AM, removed\_email\_address@domain.invalid wrote:

> I’m using that helper function with a search form to highlight the  
> typed phrase in the content BUT when my content is HTML, I’ll get  
> replacement where I don’t want to.

You want to ask this question on the Rails mailing list. This list  
is for general ruby questions.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
