Regex - matching a multiline block by noting the absence of a string and then inserting it <p>What a mouthful of a subject. </p> <p>So in essence I have a pattern I need to find in a file based on that pattern missing something.</p> <p>For example what I HAVE is:</p> <pre><code>Huge amounts of preceding code... someHeader { someInfo = "blah blah blah"; } Huge amounts of ending code... </code></pre> <p>What I need to do is make it look like this:</p> <pre><code>someHeader { someDescription = "Excellent information found here!"; someInfo = "blah blah blah"; } Huge amounts of ending code... </code></pre> <p><strong>The bottom line:</strong> I need to find all instances of the "someHeader" block that do not have a "someDescription" and insert it. "someInfo" will not always be there either so I really need to find every instance of <code>"someheader\r\t\t{\r\t\t\t!someDescription"</code> and replace it with <code>"someheader\r\t\t{\r\t\t\tsomeDescription = "Excellent information found here!";\r"</code></p> <p>I really am at a loss and have been banging on this for about a day. I have attempted <a href="/questions/tagged/sed" class="post-tag" title="show questions tagged &#39;sed&#39;" rel="tag">sed</a>, <a href="/questions/tagged/awk" class="post-tag" title="show questions tagged &#39;awk&#39;" rel="tag">awk</a>, <a href="/questions/tagged/perl" class="post-tag" title="show questions tagged &#39;perl&#39;" rel="tag">perl</a> and am dorking around with <a href="/questions/tagged/c%23" class="post-tag" title="show questions tagged &#39;c#&#39;" rel="tag">c#</a> right now.</p>