# How to ignore case in highlight() function?

**URL:** <https://www.ruby-forum.com/t/how-to-ignore-case-in-highlight-function/173020>\
**Category:** Rails\
**Created:** [July 31, 2009, 1:10pm UTC](https://www.ruby-forum.com/t/how-to-ignore-case-in-highlight-function/173020 "2009-07-31T13:10:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [July 31, 2009, 1:10pm UTC](https://www.ruby-forum.com/t/how-to-ignore-case-in-highlight-function/173020/1 "2009-07-31T13:10:54Z")

</div>

how to ignore case in highlight() function?

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [August 3, 2009, 4:52am UTC](https://www.ruby-forum.com/t/how-to-ignore-case-in-highlight-function/173020/2 "2009-08-03T04:52:57Z")

</div>

Joao S. wrote:

> how to ignore case in highlight() function?

Rails uses /i on when creating the Regexp for matching in the highlight  
method, this makes the regular expression ignore case. So it seems it  
already behaves as you want.

> <https://github.com/rails/rails/blob/a147becfb86b689ab25e92edcfbb4bcc04108099/actionpack/lib/action_view/helpers/text_helper.rb#L110>

Best,  
Michael G.
