Negative Look Ahead Python Regex
I would like to regex match a sequence of bytes when the string '02 d0' does not occur at a specific position in the string. The position where this string of two bytes cannot occ
Solution 1:
Lookaheads are "zero-width", meaning they do not consume any characters. For example, these two expressions will never match:
(?=foo)bar
(?!foo)foo
To make sure a number is not some specific number, you could use:
(?!42)\d\d # will match two digits that are not 42
In your case it could look like:
(?!02)[\da-f]{2} (?!0d)[\da-f]{2}
or:
(?!02 d0)[\da-f]{2} [\da-f]{2}
Post a Comment for "Negative Look Ahead Python Regex"