Regex pattern to find all matches in string with conditions
I am currently stuck with a regex problem.
I have a string:
Take dog, dog, dog, cat, dog;
Dont dog, dog, cat, dog;
How would I match all of the “dog” and skip “cat” with pcre2 regex engine.
The output I want is:
dog, dog, dog, dog;
This would be taken from the first line, because it starts with “Take” which is static. I cannot use any \s* in backtracking, because this doesnt support infinate backtracking.
The regex will be used in another tool, so only pure regex is allowed (no scripting).
Read more here: Source link
