1

Possible Duplicate:
Remove all multiple spaces in Javascript and replace with single space

How can I replace, for instance this:

"  "
"   "
"    "
"     "

with

" "

How can I replace all the empty space characters with a single empty char using regex?

Community
  • 1
  • 1

1 Answers1

6

I think myString.replace(/ {2,}/g," ") should do it.

James Montagne
  • 77,516
  • 14
  • 110
  • 130