title: sed Invalid preceding regular expression when trying to use capturing group on a search and replace
body: <p>I have a file that contains output from <code>s3bin sync</code> in a format as follows</p>
  
  <pre><code>Sync: s3://my-bin-url/source/000/000/001.jpg -&gt; s3://my-bin-url/400/x/000/000/001.jpg
  Sync: s3://my-bin-url/source/000/000/002.jpg -&gt; s3://my-bin-url/400/x/000/000/002.jpg
  Sync: s3://my-bin-url/source/000/000/003.jpg -&gt; s3://my-bin-url/400/x/000/000/003.jpg
  </code></pre>
  
  <p>I wish to end up with a file containing the following</p>
  
  <pre><code>000/000/001.jpg
  000/000/002.jpg
  000/000/003.jpg
  </code></pre>
  
  <p>I am trying to do this using <code>sed</code> using the following command.  This is contained within a <code>#!/bin/sh</code> script, and <code>$2</code> corresponds to an absolute file path.  This file always exists.</p>
  
  <pre><code>sed --in-place --regexp-extended '/.*((?:[0-9]{3}\/){2}[0-9]{3}\.jpg)/\1/gi' $2
  </code></pre>
  
  <p>When I execute the script, I am getting the following error message</p>
  
  <pre><code>sed: -e expression #1, char 36: Invalid preceding regular expression
  </code></pre>
  
  <p>Attempts to look up this issue have not yielded any useful responses so far, only suggestions revolve around ensuring the <code>/</code> is escaped (which it is) and escaping the <code>{}</code> (which only seems to apply when not using <code>--regexp-extended</code></p>