Jason Vincent wrote:
>
> If I have a pattern that appears mulitple times (but I don't know how
> many times) in a string, how do I get at the matched text for each of
> the matches?
>
> Made up example…
>
> $string = 'ab23cdefgXX(3A5)XXhijkl23mnXX(3)XXopq432rsXX(450b)XXtuv';
>
> If ($string =~ /XX(\w\+)XX/gi){
>
> ?...
> var1 = 3A5
> var2 = 3
> var3 = 450b...
>
> }
use strict;
use warnings;
$_ = 'ab23cdefgXX(3A5)XXhijkl23mnXX(3)XXopq432rsXX(450b)XXtuv';
my @matches = /XX\((\w+)\)XX/gi;
print "$_\n" foreach @matches;
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs