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?

1 answer

  • answered 2022-05-06 20:28 ejkeep

    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.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum