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


in reply to The craziest RegExes you ever created

I don't know about crazy, but my very first PerlMonks post was a rather neat little regex to wrap text without mangling words:

s/(.{5,12}\s+)/$1\n/g

which generates (given "Check out http://www.perlmonks.org/?node_id=438189 (it has nice line-wrapping snippet)."):

Check out http://www.perlmonks.org/?node_id=438189 (it has nice line-wrapping snippet).

DWIM is Perl's answer to Gödel