Simple as the title, really.
Is there a Regex expression to remove all whitespace except one between words.
So
" Hello. How are you today? "
would become
"Hello. How are you today?"
This will do what you wish:
" Hello. How are you today? ".replace(/\s{2,}/g,' ').trim()
fiddle: http://jsfiddle.net/REAdV/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With