Friday, 12 September 2014

javascript string replace all


var str = "Hello world, welcome to the universe.";  
//I am going to replace , with | and space with -    
var newString=str.toLowerCase().replace(/,/g, "|").replace(/ /g,'-');