title: ruby, how can I remove a space at the end with gsub?
body: <p>This removes all spaces:</p>
  
  <pre><code>irb(main):021:0&gt; 'gff gf ggfgfg '.gsub(' ','')
  =&gt; "gffgfggfgfg"
  </code></pre>
  
  <p>but I want just to remove the space at the end,</p>
  
  <p>something like </p>
  
  <pre><code>irb(main):023:0&gt;  'gff gf ggfgfg '.gsub([*' '$],'')
  </code></pre>
  
  <p>but I get:</p>
  
  <pre><code>SyntaxError: compile error
  (irb):25: syntax error, unexpected $undefined, expecting ']'
  'gff gf ggfgfg '.gsub([*' '$],'')
                              ^
      from (irb):25
      from :0
                             ^
      (irb):23: syntax error, unexpected ',', expecting $end
      'gff gf ggfgfg '.gsub(^' ','')
                                 ^
          from (irb):23
          from :0
  </code></pre>
  
  <p>n.b. I can't use truncate, trim and other rails helpers.</p>