The script:

#!perl -w
use strict;

my $str = "Account \@id='1' or \@id='2' or \@id='3' or \@id='4'";

my $reg = qr{(?:\@id='(\d+)'\s*or\s*)*\@id='(\d+)'};

if ($str =~ $reg) {
        print "Matched\n";
        print "1 = $1\n" if defined($1);
        print "2 = $2\n" if defined($2);
        print "3 = $3\n" if defined($3);
        print "4 = $4\n" if defined($4);
}


almost works, but only $1 and $2 contain captured values (3 and 4), how do I
capture the first two ids in the repetition? (In the real case the matched
string will contain any number, from 1, of "id='\+'" expresses, and I want
all of them!)

Richard Cox 
Senior Software Developer 
Dell Technology Online 
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer


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

Reply via email to