I have beneficiaries that may or may not exist on multiple lines. How can I match <Beneficiaries and ignore the lines inside that element? I can only regex when I know the exact number of lines. I want to be able to skip the lines since the number of beneficiaries is always different and match the bottom portion. The goal is to combine this with another regex if possible.
<Beneficiaries />
<PlanMapping />
<EnrollmentMapping>
<Beneficiaries>
<Beneficiary>
<Benefit>Life</Benefit>
<BenefitRelationship>Spouse</BenefitRelationship>
<DOB>1235-12-12T00:00:00</DOB>
<Primary>true</Primary>
<Person>true</Person>
<FirstName>john</FirstName>
<MiddleName />
<LastName>doe</LastName>
<SSN />
<PercentShare>100.00</PercentShare>
<PlanMapping />
<EnrollmentMapping>
<EnrollmentMapping>
<EnrollmentLocationCode>
<Value>01000008-StackOverflow</Value>
</EnrollmentLocationCode>
</EnrollmentMapping>
<PlanIdentifier>b4354773-bc6e-41e1-64ad-46abd4c35547</PlanIdentifier>
<MaintenanceCodeDate xsi:nil="true" />
Regex pattern
Beneficiaries(?=.*01000008)
https://regex101.com/r/Wce8Kn/2
Non-regex solution: I duplicated the file, ran one regex and another to compare side-by-side. It reduced the number of matches from 107 to 5.