ruby - gsub variable regardless of case -


i have following code set highlight parts of phrase word is. function regardless of case struggling syntax. believe need add /i somewhere, not know where.

params.fetch('phrase').gsub(params.fetch('word'),   '<span class="ko-highlight">' + params.fetch('word') + '</span>') 

this should trick

params.fetch('phrase').gsub(/#{params.fetch('word')}/i, '<span class="ko-highlight">' + params.fetch('word') + '</span>') 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -