title: Match regex if it does not contain string
body: <p>There are a lot of places that show you to match a string that does not contain a word. What I want to do is to use a regular expression to match a string and then test if that string contains a word.</p>
  
  <p>In other words this is what am I looking for:</p>
  
  <p>I have the text:    </p>
  
  <p>.........(note every chunk starts with &lt;"number">&lt;"hex number">)</p>
  
  <pre><code>&lt;1&gt;&lt;35c&gt;: Abbrev Number: 7 (DW_TAG_array_type)
      &lt;35d&gt;   DW_AT_sibling     : &lt;0x369&gt; 
      &lt;361&gt;   DW_AT_type        : DW_FORM_ref4 &lt;0x4d01&gt;   
  &lt;2&gt;&lt;366&gt;: Abbrev Number: 8 (DW_TAG_subrange_type)
      &lt;367&gt;   DW_AT_upper_bound : 127 
  &lt;1&gt;&lt;369&gt;: Abbrev Number: 7 (DW_TAG_array_type)
      &lt;36a&gt;   DW_AT_sibling     : &lt;0x377&gt; 
      &lt;36e&gt;   DW_AT_type        : DW_FORM_ref4 &lt;0x4d01&gt;   
  &lt;2&gt;&lt;373&gt;: Abbrev Number: 8 (DW_TAG_subrange_type)
      &lt;374&gt;   DW_AT_upper_bound : 511 
  &lt;1&gt;&lt;377&gt;: Abbrev Number: 9 (DW_TAG_structure_type)
      &lt;378&gt;   DW_AT_sibling     : &lt;0x4cb&gt; 
      &lt;37c&gt;   DW_AT_name        : mem_pool    
      &lt;385&gt;   DW_AT_byte_size   : 68  
  &lt;2&gt;&lt;386&gt;: Abbrev Number: 10 (DW_TAG_member)
      &lt;387&gt;   DW_AT_type        : DW_FORM_ref4 &lt;0x4d28&gt;   
      &lt;38c&gt;   DW_AT_accessibility: 1  (public)
      &lt;38d&gt;   DW_AT_name        : Type    
      &lt;392&gt;   DW_AT_data_member_location: 2 byte block: 23 0  (DW_OP_plus_uconst: 0)
  &lt;1&gt;&lt;357&gt;: Abbrev Number: 9 (DW_TAG_structure_type)
      &lt;37c&gt;   DW_AT_name        : mem_pool2   
      &lt;385&gt;   DW_AT_byte_size   : 28  
  &lt;1&gt;&lt;35c&gt;: Abbrev Number: 7 (DW_TAG_array_type)
      &lt;378&gt;   DW_AT_sibling     : &lt;0x4cb&gt; 
      &lt;37c&gt;   DW_AT_name        : mem_pool    
      &lt;385&gt;   DW_AT_byte_size   : 68
  </code></pre>
  
  <p>then to get the chunks that have <code>DW_TAG_structure_type</code> I use the regex expression:</p>
  
  <pre><code>(?s)\n[^\n]+?DW_TAG_structure_type.*?(?=..\d+&gt;&lt;)    
  </code></pre>
  
  <p>that matches:</p>
  
  <p>1)</p>
  
  <pre><code> &lt;1&gt;&lt;377&gt;: Abbrev Number: 9 (DW_TAG_structure_type)
      &lt;378&gt;   DW_AT_sibling     : &lt;0x4cb&gt; 
      &lt;37c&gt;   DW_AT_name        : mem_pool    
      &lt;385&gt;   DW_AT_byte_size   : 68  
  </code></pre>
  
  <p>and</p>
  
  <p>2)</p>
  
  <pre><code>&lt;1&gt;&lt;357&gt;: Abbrev Number: 9 (DW_TAG_structure_type)
      &lt;37c&gt;   DW_AT_name        : mem_pool2   
      &lt;385&gt;   DW_AT_byte_size   : 28  
  </code></pre>
  
  <p><strong>now my question is</strong> I will like to exclude the first match if it contains the string <code>sibling</code>. So what I have done to try to solve the problem was:</p>
  
  <pre><code> (?s)(?!.*sibling)\n[^\n]+?DW_TAG_structure_type.*?(?=..\d+&gt;&lt;)
  </code></pre>
  
  <p>note I added <code>(?!.*sibling)</code> to first look around to test that the word sibling is not there. that does not match anything though.  </p>
  
  <h2>Edit</h2>
  
  <p>It will be nice if my first regular expression:</p>
  
  <pre><code> (?s)\n[^\n]+?DW_TAG_structure_type.*?(?=..\d+&gt;&lt;) 
  </code></pre>
  
  <p>I could capture it in a group and then test for what I need. Doing something like</p>
  
  <pre><code> (?s)(\n[^\n]+?DW_TAG_structure_type.*?(?=..\d+&gt;&lt;))(?=\1 "if group1 cointains sibling then..."
  </code></pre>