http://qs1969.pair.com?node_id=561313


in reply to regex for multiple capture within boundary

my @nums = $x =~ /(\S+)/g;
or
my @nums = split(' ', $x);

Update: Oops, misread. How about

# @nums = ('1', '11', '2', '22', '222', '3', '33'); my @nums = $x =~ /(\d+)/g;

or

# @nums = (['1', '11'], ['2', '22', '222'], ['3', '33']); my @nums = map { [ /(\d+)/g ] } $x =~ /(\S+)/g;

I'm not clear on which one you want.

Update: Ah! Now I understand! How did I miss that?

# @nums = ('2', '22', '222'); my @nums = ($x =~ /\s(\S+)/)[0] =~ /(\d+)/g;

or

# @nums = ('2', '22', '222'); my @nums = (split(' ', $x, 3))[1] =~ /(\d+)/g;