On Jul 18, [EMAIL PROTECTED] said:

>my $str = "Account \@id='1' or \@id='2' or \@id='3' or \@id='4'";
>
>my $reg = qr{(?:\@id='(\d+)'\s*or\s*)*\@id='(\d+)'};

It doesn't work because of the way quantifiers (like *) work on
sub-patterns.

To get around it, use a global match:

  if ($str =~ /Account /g) {
    push @IDs, $1 while $str =~ /\G\@id='(\d+)'(?: or |$)/g;
  }

There are other, more fiendish ways of doing what you request (with ONE
regex), but I dare not show them here.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to