title: OS X sed -E doesn't accept extended regular expressions
body: <p>I've been trying various ways to do some basic things with sed on OS X. Here are the results of some simple tests.</p>
  
  <pre><code>echo "foo bar 2011-03-17 17:31:47 foo bar" | sed 's/foo/FOUND/g'
  </code></pre>
  
  <p>returns (as expected)</p>
  
  <pre><code>FOUND bar 2011-03-17 17:31:47 FOUND bar
  </code></pre>
  
  <p>but</p>
  
  <pre><code>echo "foo bar 2011-03-17 17:31:47 foo bar" | sed -E 's/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/FOUND/g'
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>foo bar 2011-03-17 17:31:47 foo bar
  </code></pre>
  
  <p>and (even more irritatingly)</p>
  
  <pre><code>echo "food bar 2011-03-17 17:31:47 food bar" | sed -E 's/\d/FOUND/g'
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>fooFOUND bar 2011-03-17 17:31:47 fooFOUND bar
  </code></pre>
  
  <p>Now, the <code>man sed</code> pages say that</p>
  
  <pre><code>The following options are available:
  
   -E      Interpret regular expressions as extended (modern) regular
           expressions rather than basic regular expressions (BRE's).  The
           re_format(7) manual page fully describes both formats.
  </code></pre>
  
  <p>and <code>man re_format</code> says</p>
  
  <pre><code>          \d  Matches a digit character.  This is equivalent to
            `[[:digit:]]'.
  </code></pre>
  
  <p>And indeed: </p>
  
  <pre><code>echo "foo bar 2011-03-17 17:31:47 foo bar" | sed -E 's/[[:digit:]]{4}/FOUND/g'
  </code></pre>
  
  <p>gives me</p>
  
  <pre><code>foo bar FOUND-03-17 17:31:47 foo bar
  </code></pre>
  
  <p>...but this is annoying. Either because I'm being dense, or because the man pages are <em>lying to me</em> (to be honest, I'd prefer the former).</p>
  
  <p>A quick literature review here on SO suggests that I am not alone in this, and that many recommend installing <code>GNU coreutils</code> (or indeed use something else - say <code>perl -pe</code>) -- however, I'd like to be certain: </p>
  
  <p>Do EREs work with <code>sed</code> as it is bundled with OS X -- as implied by the <code>man</code> pages -- or not? </p>
  
  <p>(I'm on 10.8 and 10.6.8)</p>