Possible Duplicate:
Case insensitive string replacement in JavaScript?
I am trying to highlight part of a string where it is equal to another variable value.
For example
var string = 'This Is A Test String';
var findWord = 'test';
result should be
'This Is A <b>Test</b> String'
Please note the case insensitive and that I require the use of using variables to pass the 'find/Replace word'
reason I need to do it this was is to keep the exact form/case of the string found where is == to the search word.
In PHP, this works, so basically I'm after the JS equivalent of
preg_replace('/('.$search.')/i','<b>$1</b>',$val['name'])
I'm not good when it comes to regex, this should be simple for someone.