in reply to Re: string match using with an N in any position
in thread string match using with an N in any position
You can just dosub fuzzy { my $string = shift; my @alt; for(my $i = 0; $i < length($string); $i++) { my $alt = $string; substr($alt, $i, 1) = 'N'; push @alt, $alt; } return join '|', $string, @alt; # original too } print fuzzy('GCGAT');
Note the parens for grouping.$re = fuzzy($string); if($value =~ /^($re)/) { ... }
If there's only one value for $re during the run of the file, you can use /o (as in /^($re)/o) but in a modern perl I don't think that makes much difference.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: string match using with an N in any position
by Marshall (Canon) on Nov 22, 2011 at 00:09 UTC | |
by bart (Canon) on Nov 22, 2011 at 18:00 UTC |