title: using sed to lazy find and replace across multiple lines
body: <p>I'm trying to use <code>sed</code> to remove blocks of html code from a file. The block to be remove appears multiple times in the file and also spans multiple lines. Also of notes the block has different content in it but has clear start and end delineations.</p>
  
  <p>I have tried a number of approaches to get this to work and am running into issues getting laziness working in <code>sed</code> and matching across lines.</p>
  
  <p>Here is an example of what I'm trying to do: </p>
  
  <pre><code>good stuff a
  good stuff same line START
  bad stuff 1.0
  bad stuff 1.1
  END
  good stuff b
  good stuff b
  good stuff same line START bad stuff 2.0
  bad stuff 2.0
  END
  good stuff c
  </code></pre>
  
  <p>Becomes:</p>
  
  <pre><code>good stuff a
  good stuff same line
  good stuff b
  good stuff b
  good stuff same line
  good stuff c
  </code></pre>
  
  <p>Here are some approaches I have tried so far.</p>
  
  <p><code>sed -n '1h;1!H;${;g;s/START.*END//mg;p;}' &lt; test &gt; test2</code>  Gets across lines to work.</p>
  
  <p><code>sed -n 's/START[^END]*END//g' &lt; test &gt; test2</code> Only negates E or N or D.</p>
  
  <p><code>sed -n 's/START.*?END//g' &lt; test &gt; test2</code> Doesn't behave with laziness.</p>
  
  <p>Thank you.</p>