On 3/2/06, Jason Vincent <[EMAIL PROTECTED]> 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...
>
> }
>
>


> To unsubscribe:
> http://listserv.ActiveState.com/mailman/mysubs
>
>

don't know if regex works in while conditional...

my @matches = ();
while ($str =~ m/XX(\w+)XX/sig)
{
   push($1, @matches);
}

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to