At first I thought it was magic. Once I know what the trick is I though “Oh”. It’s like magic IRL.
It’s pretty useless anyway since you have to have unary representation and I can’t imagine this being any fast on a large number.
Unfortunate that the overloading of ‘regular expressions’ like this blurs the line between formal regular expressions and regular expressions as provided by most programming languages.