Use str.trim() instead of str.replace(/^\s+|\s+$/g, '')

It behaves exactly same

References:
  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
Merge pull request #21 from simnalamburt/trim

Use str.trim() instead of str.replace(/^\s+|\s+$/g, '')