Reputation: 1350
I have used script to remove the double spaces. but this script is removing the new line also along with the space.
Suppose Input is "\s\s\n\n" Script's output is "\s" Desired Output "\s\n\n" That I simply want to remover double space but not new line. Want to skip new line.
function clean(f) {
f.value=f.value.replace(/^\s+|\s+$/g,'').replace(/\s\s+/g,' ');
return true;
}
Upvotes: 0
Views: 467
Reputation: 73292
You're currently using \s
which expunges any whitespace. If you wish to remove double or greater spaces whilst retaining all \n
you can use the following:
replace(/ {2,}/g,'')
Upvotes: 2