title: Modifying existing regex, excluding some parts
body: <p>I have an expression in regex, as follow:</p>
  
  <p><code>r"(?:AND|OR|SUB|ADD)\([^()]*\)(?:\]\[|\[|)(|\s\[|\s)COIL\(Seq\[\d+]\.Bool\[\d+]\.\d+"</code></p>
  
  <p>Usually I am using it to capturing from a sentence like that:</p>
  
  <p><code>AND(Seq[1].Mat)AND(Type_G012.WithData)[COIL(Seq[1].Bool[93].11),XIC(Seq[1].exp)RES(Seq[1].ita)]</code></p>
  
  <p>So I want to extract the last "AND" or "OR" or "SUB"... also with Seq[1].Bool[93].11.
  After that I am doing an additional extraction. It was working with no problems with almost everything. The problem is that I have some patterns like that.</p>
  
  <p><code>AND(Seq[1].Mat)AND(Type_G014.WithData)AND(Type_G015.WithData)[SET(Seq[1].WaitStep)COIL(Seq[1].Seq[93].10),AND(Seq[1].exp)RES(Seq[1].ita)]</code></p>
  
  <p>Then I am not capturing the last AND, OR, SUB, etc. Because now I have the SET instruction in the middle of the AND and the COIL. So I want to exclude anything diferent of <code>AND|OR|SUB|ADD</code> Because I would like to extract from the last sentence as follow:</p>
  
  <p><code>AND(Type_G015.WithData)[SET(Seq[1].Wait)COIL(Seq[1].Seq[93].10</code></p>
  
  <p>Then is the last AND before the COIL. If something could help me I am testing several things and I am messing it.</p>
  
  <p>Thanks.</p>