title: replace empty space with dash only if trailing string
body: <p>I'm using regEx and replace method to replace an empty space with a dash but I only want this to happen if there is a following character. For example
  if the input field looked like this then replace empty space between temp and string with dash</p>
  
  <pre><code>input = "temp string";
  </code></pre>
  
  <p>if it looked like this then it would just remove the empty space </p>
  
  <pre><code>input = "temp  ";
  </code></pre>
  
  <p>here is my regEx replace right now. But not sure how to check if there are trailing characters.</p>
  
  <pre><code>input.value.replace(/\s+/g, '-');
  </code></pre>