Page 1 of 1

Funny regexp: /^1?$|^(11+?)\1+$/

Posted: Thu Oct 07, 2010 1:08 am
by Cyril
I have found this funny regexp here, guess what it matches? Or check it with newLISP:

Code: Select all

(for (i 1 100)
  (unless (regex {^1?$|^(11+?)\1+$} (dup "1" i))
    (print i " ")))
Astonishing! ;-)

Re: Funny regexp: /^1?$|^(11+?)\1+$/

Posted: Thu Oct 07, 2010 5:19 pm
by cormullion
Cool. Someone explain it to me ... :/

Re: Funny regexp: /^1?$|^(11+?)\1+$/

Posted: Thu Oct 07, 2010 9:17 pm
by Lutz
There is a nice explanation here:

http://zmievski.org/2010/08/the-prime-that-wasnt