vit has asked for the wisdom of the Perl Monks concerning the following question:

In this code
my $ppc_pat = qr/<bidListing\sbidId=\"\d+\"/; my $ppc_pat_2 = qr/<\/bidListing/; my (@ar) = $xml =~ /($ppc_pat).+?$ppc_pat_2/g;
I want to collect all occurencies of $ppc_pat when after some set of symbols it is concluded with $ppc_pat_2. I thought if I put .+? this will serve my purpose. But it does not work.

Replies are listed 'Best First'.
Re: Non- greedy regex question
by state-o-dis-array (Hermit) on Dec 02, 2010 at 23:03 UTC
    With $xml set as
    my $xml = '<bidListing bidId="1234">other stuff here</bidListing>more +stuff here<bidListing bidId="5678">other stuff here</bidListing>';
    it works for me. I think that some sample data and better explanation of "it does not work" will help someone provide a solution. And have you considered using one of the xml modules instead of regex?

      you can use XML::LibXML module for this work

      Thanks And Regards,
      yuvanbala