%cat = ( 'C[AEIOU]NWAY' => 'AAA', '(BOSTON|CHICAGO)' => 'BBB', '(LAS VEGAS|NEVADA)' => 'CCC', '(DALLAS|AUSTIN)' => 'DDD', '(NASHVILLE|M[AEIOU]MPHIS)' => 'EEE' ); $variable = 'CHICAGO'; for (keys %cat) { next unless $variable =~ /$_/; print "$variable maps to $cat{$_}\n"; last; }
Dingus
In reply to Re: hash key regular expression pattern
by dingus
in thread hash key regular expression pattern
by wsee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |