Possible Duplicate:
Remove all multiple spaces in Javascript and replace with single space
我该如何替换,例如:
" "
" "
" "
" "
与
" "
我如何使用正则表达式将所有空白字符替换为一个空字符?
最佳答案
我认为myString.replace(/ {2,}/g," ")
应该这样做。
关于javascript - RegEx如何用一个空格替换多个空格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6984032/