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]
Re: Regex, how to capture within repetition?
Jeff 'japhy/Marillion' Pinyan Wed, 18 Jul 2001 05:30:09 -0700
- Regex, how to capture within repetition? Richard_Cox
- Re: Regex, how to capture within repeti... Jeff 'japhy/Marillion' Pinyan
- Re: Regex, how to capture within repeti... Jos I. Boumans
- Fw: Regex, how to capture within repeti... insomniak