title: substitute characters but not the last one
body: <p>I have a string for example like this:</p>
  
  <pre><code>str = 'TEST;NAME=1;TARGET_SOMETHING;PLATFORM_INTEL;'
  </code></pre>
  
  <p>Now I would like to substitute all <code>";"</code> with <code>"-D"</code> and delete the last <code>";"</code></p>
  
  <p>I'm doing it with:</p>
  
  <pre><code>str.gsub(/;/, ' -D').gsub(/^/, ' -D')
  </code></pre>
  
  <p>the second <code>gsub</code> is only to add the <code>-D</code> also to the beginn of line</p>
  
  <p>Result: </p>
  
  <pre><code>-DTEST -DNAME=1 -DTARGET_SOMETHING -DPLATFORM_INTEL -D
  </code></pre>
  
  <p>How to tell Ruby not to output the last <code>"-D"</code> or to delete the last <code>";"</code> in <code>str</code>?</p>
  
  <p>Any suggestions to do it in the same line?</p>