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

Started by Cyril, October 06, 2010, 06:08:31 PM

Previous topic - Next topic

Cyril

I have found this funny regexp http://www.kite-language.org/article/something-fun-to-try/">here, guess what it matches? Or check it with newLISP:
(for (i 1 100)
  (unless (regex {^1?$|^(11+?)1+$} (dup "1" i))
    (print i " ")))

Astonishing! ;-)
With newLISP you can grow your lists from the right side!

cormullion

#1
Cool. Someone explain it to me ... :/

Lutz

#2
There is a nice explanation here:



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