title: Javascript and regex: remove space after the last word in a string
body: <p>I have a string like that:</p>
  
  <pre><code>var str = 'aaaaaa, bbbbbb, ccccc, ddddddd, eeeeee ';
  </code></pre>
  
  <p>My goal is to delete the last space in the string. I would use,</p>
  
  <pre><code>str.split(0,1);
  </code></pre>
  
  <p>But if there is no space after the last character in the string, this will delete the last character of the string instead.</p>
  
  <p>I would like to use </p>
  
  <pre><code>str.replace("regex",'');
  </code></pre>
  
  <p>I am beginner in RegEx, any help is appreciated.</p>
  
  <p>Thank you very much.</p>