title: Merge Multiple spaces to single space; remove trailing/leading spaces
body: <p>I want to merge multiple spaces into single space(space could be tab also) and remove trailing/leading spaces.</p>
  
  <p>For example...</p>
  
  <pre><code>string &lt;- "Hi        buddy        what's up    Bro" 
  </code></pre>
  
  <p>to</p>
  
  <pre><code>"Hi buddy what's up bro"
  </code></pre>
  
  <p>I checked the solution given at <a href="https://stackoverflow.com/questions/1981349/regex-to-replace-multiple-spaces-with-a-single-space">Regex to replace multiple spaces with a single space</a>. Note that don't put \t or \n as exact space inside the toy string and feed that as pattern in <code>gsub</code>. I want that in R.</p>
  
  <p>Note that I am unable to put multiple space in toy string.
  Thanks </p>