I don't understand what you mean by "My next step would be to split the string into parts that contain ABC\d+
, and perform a simple replace on the other parts.", but it looks like it is not your main issue here. Do let me know otherwise.
To match every digit that is not preceded by the keyword ABC
, then you can use this regex:
(?<!ABC|\d)\d+
This prevents the matching of a digit if there is ABC
before it, or another digit (thus preventing \d+
to match if starting from the middle of a digit.
Note that you had two parts of your string in your question moved around. I'm taking only the input that you used.
If the above doesn't work (e.g. the regex engine says the pattern in the lookbehind cannot be of variable width, or something along these lines), then the alternate equivalent is:
(?<!ABC)(?<!\d)\d+