How can I extract different number of groups of numbers from a Perl string?
I am trying to parse a string in Perl with the format:
Messages pushed to the Order Book queues 123691 121574 146343 103046 161253
I want to access the numbers at the end of the line, so I intend to do a mapping like
/(\d+)/s
My problem is that the number of values at the end contains a variable number of rows.
What's the best way to format a regex to access each of these numbers individually? I'm a C ++ developer and just learning Perl, so I'm trying to find the cleanest Perl way to achieve this goal.
Thanks for your help.
a source to share
You can use the match operator in the context of a list with a global flag to get a list of all your parentheses. Example:
@list = ($string =~ /(\d+)/g);
Your list should now contain all groups of numbers in your string. See the documentation of the matching operator for details .
a source to share