Here is my problem. I have a string with mixed case in it. I want to search regardless of case and then replace the matches with some characters either side of the matches.
This can be done using a callback function for regex replace.
var s1 = "abC...ABc..aBC....abc...ABC"; var s2 = s1.replace(/abc/ig, function (match) { return "#" + match + "#" ; } ); alert(s2);
demo : http://jsfiddle.net/dxeE9/