my %hash2 = map { ( $_, $hash1{$k} ) } grep { m/regex/ } keys %hash1;