in reply to weighting regex patterns

Try String::Approx should you not find what you want in anything specific to bioperl.

But this problem does not sound to me like a regex problem per se. I think you should back off from the code and explain your actual problem. For instance I suspect that something like the following untested code could be useful even though it sounds nothing like what you have written:

# Takes a string, returns hash of chars in string and # how many times each appears. sub char_count { my $str = shift; my %count; while ($str =~ /(.)/gs) { ++$count{$1}; } return %count; }