title: match and replace multiple newlines with a SED or PERL one-liner
body: <p>I have an input C file (myfile.c) that looks like this :</p>
  
  <pre><code>void func_foo();
  void func_bar();
  
  //supercrazytag
  </code></pre>
  
  <p>I want to use a shell command to insert new function prototypes, such that the output becomes:</p>
  
  <pre><code>void func_foo();
  void func_bar();
  void func_new();
  
  //supercrazytag
  </code></pre>
  
  <p>So far I've been unsuccessful using SED or PERL.
  What didn't work:</p>
  
  <pre><code>sed 's|\n\n//supercrazytag|void func_new();\n\n//supercrazytag|g' &lt; myfile.c
  sed 's|(\n\n//supercrazytag)|void func_new();\1|g' &lt; myfile.c
  </code></pre>
  
  <p>Using the same patterns with perl -pe "....." didn't work either.</p>
  
  <p>What am I missing ? I've tried many different approaches, including <a href="https://stackoverflow.com/questions/1164925/match-any-character-including-newlines-in-sed">this</a> and <a href="https://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n/1252191#1252191">this</a> and <a href="https://stackoverflow.com/questions/1577057/sed-find-pattern-over-two-lines-not-replace-after-that-pattern">that</a>.</p>