var rule={ 'в':'v', 'о':'o', 'т':'t', ' ':'_', } var other1='в о т' alert( other1.replace( /./g , function(a){return rule[a]||a;}));