この「問題」に対して、140byte.es 未満の小さな関数を作成しました: https://gist.github.com/3728254
HTML
<div id="str">Some text here training and more bla bla bla. We can training this... Using training you can...</div>
JS
var replaceR = function(a,b,c,d,e){e=new RegExp(b,"ig");a.innerHTML=a.innerHTML.replace(d?b:e,c)};
replaceR(document.getElementById('str'), 'training', 'runing', false);
デモ
アップデート
var string = document.getElementById('str').innerHTML,
newString = string.replace('training', 'running');
document.getElementById('str').innerHTML = newString;
http://fiddle.jshell.net/db3yc/
更新 2
var s = "Some text here training and more bla bla bla. We can training this... Using training you can...",
nth = 0,
r = (new Date().getSeconds()) % 4;
s = s.replace(/training/g, function(match, i, original) {
nth++;
return (nth === r) ? "running" : match;
});
document.write(s);
http://fiddle.jshell.net/JfYvA/