title: Python complex regex replace
body: <p>I'm trying to do a simple VB6 to c translator to help me port an open source game to the c language.
  I want to be able to get "NpcList[NpcIndex]" from "With Npclist[NpcIndex]" using ragex and to replace it everywhere it has to be replaced. ("With" is used as a macro in VB6 that adds Npclist[NpcIndex] when ever it needs to until it founds "End With")</p>
  
  <pre><code>Example:
   With Npclist[NpcIndex]
   .goTo(245) &lt;-- it should be replaced with Npclist[NpcIndex].goTo(245)
   End With
  </code></pre>
  
  <p>Is it possible to use regex to do the job?
  I've tried using a function to perfom another regex replace between the "With" and the "End With" but I can't know the text the "With" is replacing (Npclist[NpcIndex]).
  Thanks in advance</p>