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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to use regular expression for this?
by Anonymous Monk on Aug 12, 2005 at 22:48 UTC | |
by graff (Chancellor) on Aug 13, 2005 at 00:13 UTC | |
by QM (Parson) on Aug 12, 2005 at 23:09 UTC |
In Section
Seekers of Perl Wisdom