Interesting little regex

Alan Young alansyoungiii at
Thu Feb 23 09:49:00 MST 2006

In trying to get something done a co-worker came up with this little regex:

perl -e '$a="abcde"x200;$a=~s{((\w+?)(??{!$b{$^N}++?"(?=)":"(?!)"}))}{($1)}xg;print

Basically, it creates a simple hash lookup of all the unique
occurrences of the string.

It's probably not practical for a whole lot, but it's still kind of cool.

More information about the PLUG mailing list