pols commited on
Commit
b42089b
·
verified ·
1 Parent(s): cf9648a

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +7 -3
script.js CHANGED
@@ -141,9 +141,13 @@ function updateButtonStates() {
141
  }
142
 
143
  function replaceSpaces() {
144
- const text = inputText.value;
145
- const replacedText = text.replace(/ /g, ', ');
146
- inputText.value = replacedText;
 
 
 
 
147
  handleTextChange();
148
  }
149
 
 
141
  }
142
 
143
  function replaceSpaces() {
144
+ let text = inputText.value;
145
+
146
+ text = text.replace(/,(\S)/g, ', $1');
147
+ text = text.replace(/ {2,}/g, ' ');
148
+ text = text.replace(/([^,])\s+/g, '$1, ');
149
+
150
+ inputText.value = text;
151
  handleTextChange();
152
  }
153