var metin = "baris";
var icerikoku = "Hello Baris. What is surname Baris. Bye bye baris. How are you metin.";
var n = icerikoku.replace(/metin/gi, "ziya");
$("#icerikoku").html(n);
打印:
Hello Baris. What is surname Baris. Bye bye baris. How are you ziya.
但是,必须是:
Hello ziya. What is surname ziya. Bye bye ziya. How are you metin.