title: Regex Match Part of Line, Then Look Behind and Replace (and also delete that line)
body: <p>I have a string with this format:</p>
  
  <pre><code>                $something = $gateway-&gt;execute($query) or die(mysql_error() . " here");
                  $id  = mysql_insert_id();
  </code></pre>
  
  <p>This is tricky, because I want to end up with this:</p>
  
  <pre><code>$id = $gateway-&gt;execute($query) or die(mysql_error() . " here");
  </code></pre>
  
  <p>I've tried matching the mysql_insert_id line, then looking behind for $gateway->execute and replacing $something with the captured $id, but I coudln't figure it out. Is this even possible? 
  I also want to delete the mysql_insert_id line, but I could always grep and replace afterwards and replace with empty string.</p>
  
  <p>Thanks.</p>