title: sed regex to non-greedy replace?
body: <p>I am aware of <a href="https://stackoverflow.com/questions/1103149/non-greedy-regex-matching-in-sed">another question</a> that is quite similar, but for some reason I'm still having problems.</p>
  
  <p>I have a GC log that I'm trying to <em>trim out</em> the Tenured section enclosed in <code>[]</code>.</p>
  
  <pre><code>63.544: [GC 63.544: [DefNew: 575K-&gt;63K(576K), 0.0017902 secs]63.546: [Tenured: 1416K-&gt;1065K(1536K), 0.0492621 secs] 1922K-&gt;1065K(2112K), 0.0513331 secs]
  </code></pre>
  
  <p>I apply <code>s/\[Tenured:.*\]//</code></p>
  
  <p>And quite expectantly, the result is trimmed <em>greedily</em> through the remainder of the line:</p>
  
  <pre><code>63.544: [GC 63.544: [DefNew: 575K-&gt;63K(576K), 0.0017902 secs]63.546:
  </code></pre>
  
  <p>So let's try and be non-greedy <strong>not</strong> match a closing right bracket with <code>s/\[Tenured:[^\]]*\]//</code> but alas no match is made and sed skips over the line, producing the same original output:</p>
  
  <pre><code>63.544: [GC 63.544: [DefNew: 575K-&gt;63K(576K), 0.0017902 secs]63.546: [Tenured: 1416K-&gt;1065K(1536K), 0.0492621 secs] 1922K-&gt;1065K(2112K), 0.0513331 secs]
  </code></pre>
  
  <p>How do I non-greedily match and replace that section?  Thanks,</p>