title: How to remove all line breaks and white space before and after a string in jquery
body: <p>I have a string in jquery like following:</p>
  
  <pre><code>var str = "\n    \n        \n        \n            Michael Hartl\n        \n    \n";
  </code></pre>
  
  <p>but I want to fetch this string into this format as output</p>
  
  <pre><code>str = "Michael Hartl"
  </code></pre>
  
  <p>I tries with following functions:</p>
  
  <pre><code>str.replace(/\s*/," ")
  </code></pre>
  
  <p>but it results like </p>
  
  <pre><code> " Michael Hartl
  
  
  "
  </code></pre>
  
  <p>is there any other way in jquery to get the desired output?</p>