title: RegEx substitution works in Ruby gsub, but not with sed
body: <p>I'm trying to strip prefixes from a SemVer, i.e, making <code>1.2.3-prefix.42</code> into <code>1.2.3</code>.</p>
  
  <p>I'm using this RegEx found in <a href="https://github.com/mojombo/semver/issues/32#issuecomment-7663411" rel="nofollow">https://github.com/mojombo/semver/issues/32#issuecomment-7663411</a>:</p>
  
  <pre><code>^(\d+\.\d+\.\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?
  </code></pre>
  
  <p>When using Ruby's <code>gsub</code> method, it works:</p>
  
  <pre><code>puts '1.2.3-alpha.4'.gsub(/^(\d+\.\d+\.\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/, '\1')
  # =&gt; 1.2.3
  </code></pre>
  
  <p>But when using <code>sed</code> form the terminal it doesn't:</p>
  
  <pre><code>$ echo '1.2.3-alpha.4' | sed -e 's/^(\d+\.\d+\.\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/\1/g'
  $ 1.2.3-alpha.4
  </code></pre>
  
  <p>What am I missing? </p>
  
  <p>I'm using zsh on Mac OS X.</p>
  
  <p>Thanks</p>