A regular expression to check for prime numbers
For some this will be obvious, but for others it may still be interesting:<p>If this was a "true" regular expression, in the sense that it describes a regular language (<a href="http://en.wikipedia.org/wiki/Regular_language" rel="nofollow">http://en.wikipedia.org/wiki/Regular_language</a>), then checking whether the number is prime or not, by checking if the expression matches, would run in linear time. This would be worth a few nobel prizes at least.<p>Unfortunately, it is an "extended" regular expression, i.e. not regular at all in the strictest sense, and (as the article says) requires backtracking.