4 ms·
If the number N can be converted to a string of length N, this regex checks if it's divisible by 7: ^(.......)+$
by 3dfan 11y ago
If the number N can be converted to a string of length N, this regex checks if it's divisible by 7:
^(.......)+$
- meric 11y agoThat would work, use base 1 representation.
- eru 11y agoThat's not a solution. I asked for a something that checks decimal numbers. A real solution looks uglier: check out https://github.com/matthiasgoergens/Div7 https://github.com/matthiasgoergens/Div7, it starts ((((((6(2|9)8|6(2|9)1|5)(5(2|9)8|5(2|9)1|4)(5(2|9)7 [...] (Unless you can convert from decimal to unary in regex, too. I doubt you can, regular languages are too weak for that.)