title: How to check for a specific string between multiple strings with regex?
body: <p>I have this following string:</p>
  <pre><code>(...)
  &lt;TEST NAME=&quot;KBC1&quot; ID=&quot;0034&quot; PRA=&quot;RUNNING DOG&quot; /&gt;
  &lt;TEST NAME=&quot;KBC2&quot; ID=&quot;0264&quot; PRB=&quot;STANDING CAT&quot; /&gt;
  &lt;TEST NAME=&quot;KBC1&quot; ID=&quot;4632&quot; TEM=&quot;HAPPY DOG&quot; /&gt;
  &lt;TEST NAME=&quot;KBC6&quot; ID=&quot;4492&quot; LST=&quot;FLYING BIRD&quot; /&gt;
  (...)
  </code></pre>
  <p>The program should check for the word DOG, only if <em>NAME=&quot;KBC1&quot;</em> and TEM=&quot;(..)&quot; contains the word HAPPY. That would be true for the third line. It works partly with following pattern:</p>
  <pre><code>Pattern p1 = Pattern.compile(&quot;&lt;TEST NAME=&quot;KBC1&quot;(.*)\/&gt;&quot;);
  </code></pre>
  <p>How can I include the case for checking if TEM=&quot;(...)&quot; contains the word &quot;DOG&quot; without creating two patterns?</p>