1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#!/usr/bin/perl
use warnings;
use Data::Dumper;
my $start = 'AA';
my $end = 'GG';
my $min = 2;
my $max = 5;
my $reg = "
(
(?: ($start) ([ACGT]{$min,$max})? ($end) )
|
(?: ($start) ([ACGT]{$min,$max}) )
|
(?: ([ACGT]{$min,$max}) ($end) )
|
(?: ($start | $end) )
)";
$str = 'ACGAAGGGAC';
match($str, ++$try);
$str = 'ACGAAACGTAGGGAC';
match($str, ++$try);
$str = 'ACGAAACGTAGAC';
match($str, ++$try);
$str = 'ACGACGTAGGGAC';
match($str, ++$try);
$str = 'ACGAAGAC';
match($str, ++$try);
$str = 'ACGGGGAC';
match($str, ++$try);
$str = 'ACGAAACACACGTAGGGAC';
match($str, ++$try);
$str = 'ACGACACACGTAGGGAC';
match($str, ++$try);
sub match {
my ($str, $try) = @_;
print "Essai n° $try\n";
@res = $str =~ m/$reg/x;
print Dumper(@res);
print "\n";
} |