title: regexp (sed) suppress "no match" output
body: <p>I'm stuck on that and can't wrap my head around it: How can I tell sed to return the value found, and otherwise <strong>shut up</strong>?</p>
  
  <p>It's really beyond me: Why would sed return the whole string if he found nothing? Do I have to run <em>another</em> test on the returned string to verify it?  I tried using "-n" from the (very short) man page but it effectively suppresses all output, including matched strings.</p>
  
  <p>This is what I have now :</p>
  
  <pre><code>echo plop-02-plop | sed -e 's/^.*\(.\)\([0-9][0-9]\)\1.*$/\2/'
  </code></pre>
  
  <p>which returns
  <code>02</code> (and that is fine and dandy, thank you very much), but:</p>
  
  <pre><code>echo plop-02plop | sed -e 's/^.*\(.\)\([0-9][0-9]\)\1.*$/\2/'
  </code></pre>
  
  <p>returns
  <code>plop-02plop</code> (when it should return this = "" <strong>nothing</strong>! Dang, you found nothing so be quiet!
   For crying out loud !!)</p>
  
  <p>I tried checking for a return value, but this failed  too ! Gasp !!</p>
  
  <pre><code>$ echo plop-02-plop | sed -e 's/^.*\(.\)\([0-9][0-9]\)\1.*$/\2/' ; echo $?
  02
  0
  $ echo plop-02plop | sed -e 's/^.*\(.\)\([0-9][0-9]\)\1.*$/\2/' ; echo $?
  plop-02plop
  0
  $
  </code></pre>
  
  <p>This last one I cannot even believe. Is <code>sed</code> really the tool I should be using? I want to extract a needle from a haystack, and I want a needle or <em>nothing</em>..?</p>