I want to extract data relating to a few categories from a text file (except for Categories A and B). The format of the substring would be something like
some text preceding Category C This is some text I'm aware of belonging to the categories
To handle this above, excluding Category A and B data I have a simple negative lookbehind regex as
(?<!Category A )(?<!Category B )This is some text I'm aware of
However, I also have some limited cases where Category A/B in the text would be followed by a few characters (max 5). For instance:
some text Category A 1. This is some text I'm aware of belonging to the categories
So I tried changing the regex to:
(?<!Category A.{5})(?<!Category B.{5})This is some text I'm aware of
It works fine for exactly 5 characters after CatA/B, but it does not allow me to change {5} to {0,5} and complains:
quantifier not fixed
How can I get this to work?