$string =~ s/this/that/ig; --- RegEx re = new RegEx(/this/i); string = string.replace(re,"that","g");