Nishanth's Blog | All posts tagged 'character'

Javascript for replacing n th character in a string

by Nishanth 2. April 2009 04:41
   
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) ); 

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen


About Me

Nishanth Nair  

 A die hard fan of Rise of Nations... I write few softwares for McAfee Inc. for a living.

 

Portfolio:

http://morningbellnews.com
http://Necab.org
http://SufiKatha.com
http://DeepaRecipes.com
http://ManipalFoundation.in
http://NetraArts.com
http‌://EnWebTech.com
Contact : Nair.Nishanth@Gmail.com 

 

All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer.

Tag cloud

free counters