'Matching number with regex

Need a single combined regex to match the following logic: The number should be 8 digits long, the 8th digit should be the remainder of (the first 7 digits / 7).

for example: 86008786

remainder = (the first 7 digit)/ 7 = 8600878 / 7 = 6

so the 8 digit 86008786 is valid number.

is it doable with regex?



Solution 1:[1]

It is not doable with regex. You cannot do math operations. It might be possible with a unary number, but would require a conversion and would be inefficient.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 E_net4 - Krabbe mit Hüten