Prime Number Regex!

This is hardly news to the internet but it’s very much news to me, and very much awesome. I was doing some research on prime numbers for one of the Project Euler problems when I came across a regular expression that determines if a number is prime!

("1" * n) !~/^1?$|^(11+?)1+$/

Here’s an nice explanation of how it works. Neat.