title: How to combine str.replace() expressions in javascript?
body: <p>I want to combine all them expressions into one and haven't got a clue how to do it, it needs to remove the end white-space and remove the beginning white-space but shorten white-space between two words to only one (if there's more than one). Thanks</p>
  
  <pre><code>var _str = document.contact_form.contact_name.value;
  name_str = _str.replace(/\s+/g,' ');
  str_name = name_str.replace(/\s+$/g,'');
  name = str_name.replace(/^\s+/g,'');
  document.contact_form.contact_name.value = name;
  </code></pre>