Clearing a string in javascript: removing spaces, tabs
Is it possible to clear the string by removing duplicate spaces, tabs, and line feeds, in general, so that the string is like this:
var str = "test test
test test";
And it became like this
var str = "test test test test";
I know $.trim
in jQuery
for this, but it will then remove just spaces at the end and beginning of the string.
Maybe there is a plugin, or a function?
3
1 answers
"test test test".replace(/\s{2,}/g, ' ');
12
Author: Zhukov Roman, 2012-12-28 12:54:43