To make it a general solution, you need to add quotemeta and you gotta be careful about ordering if one key can be the the start of another key. And if you're going to add (?:), you might as well use qr//.
my ($pat) = map qr/$_/, join '|', map quotemeta, sort { length($b) <=> length($a) } keys %value_lkup; my @data = map $value_lkup{$_}, /$pat/g;
In reply to Re^3: regex question
by ikegami
in thread regex question
by nate_
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |