Tuesday, December 20, 2011

Replace white spaces – blank spaces in string using Javascript



function ReplaceWhiteSpaces()
{
 var text = "Example to Replace white spaces in strings";
 text = text.replace(/\s/g, "-");
 alert(text);
}

Output : Example-to-Replace-white-spaces-in-strings
Regex Used : /\s/g

No comments :

Post a Comment