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