I don't disagree with your commentary about the crappy regex. It isn't mine though, it is what the OP had.
And, while it's true that my solution has some serious shortcomings, your solution has its own set of problems. The OP said that he needs the $key value later to get values out of the hash. If it is a precompiled regex, he can't use it. You'll probably need to compile a hash of key, regex pairs, but that will raise issues of ordering again. Also, $s contains the lc string, I think you meant $_ in the print line. That's just a typo though.
In reply to Re^3: Matching Many Strings against a Large List of Hash Keys (case insensitively, longest key first)
by thundergnat
in thread Matching Many Strings against a Large List of Hash Keys (case insensitively, longest key first)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |