http://www.perlmonks.org?node_id=558982


in reply to The craziest RegExes you ever created

My craziest regex:

use re 'eval'; my $string = "abc"; my $length = length $string; my $regex = qr/(\G[$string]{0,$length}(?{print "# [$&][$'][$string]\n"}))/ x + 2; $string =~ $regex;

Bonus points if you can figure out why I wrote that. As a fun exercise, try to figure out what it does and how it does it.

Of course, this forking regular expression might top it. Since the regex engine is not re-entrant, if you need that power, you have to fork.

Cheers,
Ovid

New address of my CGI Course.