title: jquery/javascript how to get rid of blank spaces (replace() not working)
body: <p>Hi all, </p>
  
  <p>I have a string coming from my database: </p>
  
  <pre><code>var theString = "LNDSH   - LONDON SHOPS";
  </code></pre>
  
  <p>I need to get two variables out of it. </p>
  
  <p>One with the code before the -, and the other one with the sentence after the -.</p>
  
  <p>To do so I do: </p>
  
  <pre><code>var sentence = $.trim(theString.substring((theString.indexOf('-')+1),theString.length)); 
  var code = $.trim(theString.substring(0, theString.indexOf('-')));
  </code></pre>
  
  <p>var sentence is ok, but I cannot get rid of the spaces before the - in the code variable. </p>
  
  <p>I really need to get rid of those spaces.  </p>
  
  <p>Please note that in var sentence I'm doing +1 because it is always one space in between the sentence and the -.</p>
  
  <p>But in the case of the code: I don't know the length of the code and I don't know how many spaces will be before the -</p>
  
  <p>I've tried:</p>
  
  <pre><code>code.replaceAll("\\s+", " "); 
  </code></pre>
  
  <p>But this does not show a thing in my page (no javascript errors either).</p>
  
  <p>I'm using jquery-1.5.1.min and jquery-ui-1.8.14.custom.min</p>
  
  <p>Thanks a lot!</p>