title: How to check regex and only then substitute?
body: <p>I have a lot of similar files that contains</p>
  
  <pre><code>&lt;id="1" status="one" group="first" city="CITY" ... &gt;
  &lt;id="2" status="three" group="first" city="CITY" ... &gt;
  &lt;id="3" status="two" group="first" city="CITY" ... &gt;
  &lt;id="4" status="one" group="first" city="CITY" ... &gt;
  </code></pre>
  
  <p>Now I want to go through all files and add <code>bonus="yes"</code> for all, except <code>status="two"</code></p>
  
  <pre><code>&lt;id="1" status="one" bonus="yes" group="first" city="CITY" ... &gt;
  &lt;id="2" status="three" bonus="yes" group="first" city="CITY" ... &gt;
  &lt;id="3" status="two" group="first" city="CITY" ... &gt;
  &lt;id="4" status="one" bonus="yes" group="first" city="CITY" ... &gt;
  </code></pre>
  
  <p>I have simple regex match, which has three capturing groups</p>
  
  <ol>
  <li>full</li>
  <li><code>&lt;id="_" status="__"</code></li>
  <li><code>group="___" city="___" ... &gt;</code></li>
  </ol>
  
  <p>I know I can add the line somewhere like this</p>
  
  <pre><code>with open(fileName) as currentFile:
      content = (currentFile.read())
  content = re.sub(regex, f"\\1 {line_to_add} \\2", content)
  with open(fileName, "w") as f:
      f.write(content)
  </code></pre>
  
  <p> How to perform check when <code>status="two"</code> to pass them ?</p>