I am trying to parse a string and extract some numbers from it. In principle, any 2-3 digits should be matched, with the exception of those that have a "TEST" in front of them. Here are some examples:
TEST2XX_R_00.01.211_TEST => 00, 01, 211
TEST850_F_11.22.333_TEST => 11, 22, 333
TESTXXX_X_12.34.456 => 12, 34, 456
Here are some of the things I've tried:
(?<!TEST)[0-9]{2,3}
- ignores only the first digit after TEST
_[0-9]{2,3}|\.[0-9]{2,3}
- Correctly matches numbers, but matches the character in front of them (_ or.).
I know that this may be a duplicate of a regular expression to match something if it is not preceded by something else , but I could not get my answer there.
source
share