I would like to match the following pattern in multiple lines
- The pattern begins with "PAT_A"
- The pattern ends with the first ";" after "PAT_A"
- The pattern contains "PAT_B" between "PAT_A" and ";"
- The pattern does not contain "NOT_MATCH_THIS" between "PAT_A" and ";"
For example, this should make a match
PAT_A_YYY(
OK,
PAT_B
);
And this should not make a match.
PAT_A_XXX(
NOT_MATCH_THIS,
PAT_B
);
I managed to fulfill the first three requirements with
(PAT_A[^;]*?)(\bPAT_B\b)([^;]*;)
where the groups are for extracting the different parts matched.
However, I did not succeed in excluding matches containing "NOT_MATCH_THIS".
I have checked the post "How to negate specific word in regex?" about negative lookahead. However, it seems that the answer there matches the whole line instead of the pattern requirement described above. And I am not sure how I should incorporate the negative lookahead into my regex pattern.
Is there any way I could match with regex fulfilling all the four requirements?