I’m new to regex, and I've spent a fair amount of time experimenting on regex testers, searching the web, etc. on the following issue. I’m using Python 3.7+.
Example Text String:
((AC00001234 + AC00005678) / 365) * (5 + 10)
Note - AC is always in uppercase and followed by exactly 8 digits.
Desired Outcome: A matched group with the following items. More specifically, any and all numbers not with the AC-prefix.
- 365
- 5
- 10
While I’ve tried more things than I can count, I’m come closest with a negative lookbehind (below). The problem is that the result is pulling in 00001234 and 00005678 as well. I’ve tried explicit character classes [0-9], adjusting some groupings, etc.
Current Code:
(?<!AC\d{8})\d+
Current Outcome:
- 00001234
- 00005678
- 365
- 5
- 10
On Stack Overflow, I looked at the following: Negative lookbehind in a regex with an optional prefix, Match pattern not preceded or followed by string, Standalone numbers Regex?, and Regex to identify standalone numbers.
For simplicity, I've broken down the parsing into three other steps (e.g., extracting the AC-prefix codes only, math operators, etc.), and this piece is the final one I need to solve.