[HN] A regular expression to check for prime numbers

https://www.noulakaz.net/2007/03/18/a-regular-expression-to-check-for-prime-numbers/

[ comments | sourced from HackerNews ]

6 points · 2 comments · view on lemmy.world

2 Comments

withersailor@aussie.zone · 2 pts · 3y

/^1?$|^(11+?)\1+$/

That's tricky! Neat though!

lemmyng@beehaw.org · 1 pts · 3y

Clever! Inefficient (since it's essentially a brute force), but very clever and probably worth a code golf award.