Interesting little regex

"Alan Young" <[email protected]>
Newsgroups gmane.org.user-groups.linux.provo.plug,gmane.comp.lang.perl.fun
Message-ID <[email protected]>
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
"$a\n";'

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.
--
Alan

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.