https://itnext.io/a-wild-way-to-check-if-a-number-is-prime-u...
The main trick for me was you first have to convert the number to unary, which was done outside of the regex.