in reply to Re: Parsing String
in thread Parsing String

Dave, thank you for pointing out the /g modifier! I had complete forgotten about that fact when I posted my answer.

Replies are listed 'Best First'.
Re: Re: Parsing String
by Anonymous Monk on Apr 21, 2004 at 18:56 UTC
    I couldn't get it to work I am trying to go item by item using reg. expressions.
      Well, here's a method that iterates over each of the items found:

      my $results = "Home Town, Log in activity: 57 DI activity: 13 FA activ +ity: 13 FAI activity: 4 Login activity: 23 Not Found activity: 4"; foreach my $number ( $results =~ m/\d+/g ) { print "$number\n"; }


      Dave

      I guess I don't understand what you're trying to do then. davido's code pulls out all the numbers into an array that you can the loop over and do whatever you like with. What exactly are you trying to do with your code?