title: How to trim empty space in the center of a string?
body: <p>I have dynamically generated <code>JSON</code> file with data. Some of the data generate error of an invalid <code>json</code>:</p>
  
  <pre><code>SyntaxError: JSON.parse: bad control character in string literal at line 34447 column 24 of the JSON data
  </code></pre>
  
  <p>I located problems and some of these are</p>
  
  <pre><code>"live_href": "http://   http://google.com",
  or
  "login_pass": "bourdfthuk.midas.admin   r3adqerds7one",
  </code></pre>
  
  <p>I already fixed whitespace at the beginning and end with <code>.trim()</code> but trim won't remove whitespace in the center of a string. </p>