Animated regular-expression prime test in faster Regex Powertoy

This thread at News.YC motivated me to deploy some recent improvements to Regex Powertoy. It's now noticeably faster, especially for animating regex matching, and 'matchmarks' more reliably capture the entire syntax/display/animate settings.

Considering the prime-testing regex mentioned in the thread:

We can watch this match number 49 -- essentially discovering a factor and confirming that 49 is not prime -- by visiting this matchmark:
We can watch the regex fail to match 47 -- confirming its primality -- with this matchmark:
We can further fancy things up by including a substitution string to replace not-prime numbers, and use the 'show edits' highlight mode:
s/^1?$|^(11+?)\1+$/not prime/
Note that clicking on the matched range brings up a detail view showing subgroup matches -- in this case the group's length is the factor found.

Note that Regex Powertoy requires Java -- a hidden applet makes use of Java's better-than-Javascript regex engine. (The recent changes have included replacing an old version of Prototype with the latest jQuery, and minimizing the slow JS-to-Java callouts by returning results in batches.)

Labels: , , , , , ,