Regex to check for prime numbers
noulakaz.net
noulakaz.net
For what it's worth, though, it is possible because most scripting languages make regular expressions more powerful by allowing you to match against previously captured values. As formally defined, regular expressions are not powerful enough to check whether an arbitrary number is prime.
Though to be fair, since the universe is finite, no existing computer is powerful enough to check if an arbitrarily large number is prime.
http://74.125.95.132/search?q=cache:d_FZMU2REmIJ:www.noulaka...
Cute.
http://news.ycombinator.com/item?id=230292
If your browser has Java applet support, here you can watch the regex succeed (demonstrating a number is composite) or fail (prime):
49: http://regex.powertoy.org/?pat=/^1%3F%24|^%2811+%3F%29\1+%24...
47: http://regex.powertoy.org/?pat=/^1%3F%24|^%2811+%3F%29\1+%24...
(Hmm... I'll use that as a fortune file. Just need to remove extra '%', if fortune barfs on them. Ah, haven't had fortune in my login since the 90s.)