http://qs1969.pair.com?node_id=483438


in reply to How to use regular expression for this?

Must you use a regular expression? If not, this works:
#!/usr/bin/perl use warnings; use strict; my @teststrings = qw(ABCXXXXXX AXCXXXXXX AXXDXFXXX AXXXXXXHI XXXXXXGHI + XXXXXXXXX AXXXXXXXI); my $pattern = "ABCDEFGHI"; my $desired_matches = 3; for (@teststrings) { my $result = $pattern ^ $_; my $matches = $result =~ tr/\0/ /; print "$_\n" if $matches == $desired_matches; }