I have this question where I need to determine if a number is divisible by 7 using only REGEX in python.
This is what I came up with:
0 7 14 21 ... 91 98 The numbers that appear are: 0-9 for the first and second
and all the trailing left digits can appear as many as they want so \d*
the regex is: \d*\d\d
- did the opposite, it returned true for numbers that were not divisible by 7
for example re.match(theReg, '32780')
returned False and I need it to return True, so I negated the whole regex to the very final:
~\d*\d\d
This SOMEHOW works for all the numbers, but again, the opposite, it returns False for numbers that are divisible by 7...
Another question: I did not seem to find any way to negate a regex, so how the hell does ~ do all the work?
Thanks!