title: sed error: "invalid reference \1 on `s' command's RHS"
body: <p>I run several substitution commands as the core of a <a href="https://gist.github.com/johnjohndoe/5337476" rel="noreferrer">colorize script for maven</a>.
  One of the <code>sed</code> commands uses a regular expression which works find in the shell as <a href="https://stackoverflow.com/questions/16637432/sed-error-invalid-range-end">discussed here</a>. The current (not working) implementation can be found <a href="https://gist.github.com/johnjohndoe/5337476#file-colorize-maven-sh-L103" rel="noreferrer">here</a>.</p>
  
  <p>When I include one of the variants of the command into the script different behavior occurs:</p>
  
  <p><strong>Variant 1:</strong></p>
  
  <pre><code>$ sed -re "s/([a-zA-Z0-9./\\ :-]+)/\1/g"
  </code></pre>
  
  <p><strong>Adapted to the script:</strong></p>
  
  <pre><code>-re "s/WARNING: ([a-zA-Z0-9./\\ :-]+)/${warn}WARNING: \1${c_end}/g" \
  </code></pre>
  
  <p><strong>Error:</strong> The shell outputs the same information as if I would type <code>$ sed</code>. Strange!?</p>
  
  <hr>
  
  <p><strong>Variant 2:</strong></p>
  
  <pre><code>$ sed -e "s/\([a-zA-Z0-9./\\ :-]\+\)/\1/g"
  </code></pre>
  
  <p><strong>Adapted to the script:</strong></p>
  
  <pre><code>-e "s/WARNING: \([a-zA-Z0-9./\\ :-]\+\)/${warn}WARNING: \1${c_end}/g" \
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>sed: -e expression #7, char 59: invalid reference \1 on `s' command's RHS</p>
  </blockquote>