Prime number tester

/ Published in: Regular Expression
Save to your folder(s)

By the legendary abigail. Fails to match if and only if it is matched against a prime number of 1's. That is, '11' fails, but '1111' does not.

I once heard him talk why this works, but I forgot most of it.

Copy this code and paste it in your HTML
  1. ^1?$|^(11+?)\1+$

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.