According to the String.prototype.replace() page on MDN, I should be able to easily replace multiple patterns just by using
str.replace(\'what to replace\',
It appears that webkit's implementation of string.replace perhaps doesn't have the 3rd parameter, as 'foo'.replace('o','i','g') results in fio for me.
'foo'.replace('o','i','g')
fio
The following appears to work however:
'foo'.replace(/o/gi,'i')
Another option is:
'foo'.replace(new RegExp('o', 'gi'),'i')