Given an input like @1=A1@2=A2@3=A3>>@1=B1@2=B2@3=B3>>@1=C1@2=C2@3=C3>>@1=B1@2=B2@3=B3
. I want to capture what is after @2=
when @3=B3
and also verify that when @3=B3
, then @2=
should contain the same value which was captured.
The patterns that should match are:
@1=A1@2=A2@3=A3>>@1=B1@2=B2@3=B3>>@1=C1@2=C2@3=C3>>@1=B1@2=B2@3=B3
@1=A1@2=A2@3=A3>>@1=B1@2=B2@3=B3>>@1=C1@2=C2@3=C3
The pattern that should not match
@1=A1@2=A2@3=A3>>@1=B1@2=B2@3=B3>>@1=C1@2=C2@3=C3>>@1=B1@2=B10@3=B3
@1=A1@2=A2@3=A3>>@1=B1@2=B2@3=B3>>@1=C1@2=C2@3=C3>>@1=B1@2=B10@3=B3>>@1=B1@2=B2@3=B3
The way I do this currently is in two passes, first by getting all invalid patterns by using regex @2=((?:\w|-|'|""|,|\.)+?)@3=B3.+@2=(?!\1@)((?:\w|-|'|""|,|\.)+?)@3=B3
and then removing these patterns from all the available inputs.