On 02/20/04 04:31, Öznur Taştan wrote:
You are rigth to confuse beacuse I couldn't find the mail I wrote at the
beginning that defines the problem.Sorry..
My problem was this
I have a sets of patterns
and a string
and I know in which order these patterns are supposed to exists
What I try to do was to extract the substrings when the patterns match to
the string but all the matches including the overlapping ones.
The simplified version is the one that Rob solves. That is when the sets of
pattern is H K D (H is the first pattern)
So in the link I give as far as i understood it says

If I understand the problem, what you want to do is vary the greediness of the match. One way to do that is to generate the regexs. Try this:


#!/usr/bin/perl

use strict;
use warnings;


my $seq = 'xHxxHyyKzDt';


my @pat = ( '(.+)', '(.+?)' );

my %uniq;

for my $a (0..1) {
  for my $b (0..1) {
    for my $c (0..1) {
      for my $d (0..1) {
        my $pat =    '^' .
          $pat[$a] . 'H' .
          $pat[$b] . 'K' .
          $pat[$c] . 'D' .
          $pat[$d] . '$' ;

          $uniq{"$1 $2 $3 $4"}++ if $seq =~ /$pat/;
      }
    }
  }
}

print join "\n", keys %uniq;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to