perl -lne '(1x$_) !~ /^1?$|^(11+?)\1+$/ && print "$_ is prime"'
Can I just say that testing for a prime number with one line of code is brilliant?
And it can run quickly too, the lower the divisor the faster the run time.
The algorithm however has some inefficiencies that will keep you limited to smaller numbers. It will scan to see if the number is a multiple of 2, then it will scan to see if it is a multiple of 3, then it goes on to scan for 4, which will never match because it would have stopped at 2. This inefficiencies of this algorithm cannot be overcome while using a regular expression.
However it is still really neat.