2009 April

Javascript for replacing n th character in a string

    Javascript for replacing n th character in a string:     function RepalceCharacter(sourceString,stringTobeReplaced,index) {     var re = new RegExp('^(.{'+ –index +'}).(.*)$','');     return sourceString.replace(re,'$1'+stringTobeReplaced+'$2'); };   //Test code  alert( RepalceCharacter('nishanth','XSSSSX',3) );