in reply to Regular expressions: interpolate the variable in the value of the number of repetitions for the group
The problem you want to solve is certainly solvable. However, the approach you want to take is going to be very ugly, if it's even possible at all. Here's what I would do instead:
s/(\d)//; say for (split /\n/)[0..$1-1];
However, you haven't mentioned what context this is in, and the data does seem highly contrived. What problem are you really trying to solve?
If you need to match an expression like this several times in a larger chunk of text, you'll need to split that text somehow, but you haven't given enough information for me to help you, there. (For example, split /(\d)/ first would give you an array of digits and strings to loop over.)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regular expressions: interpolate the variable in the value of the number of repetitions for the group
by 0day (Sexton) on Aug 03, 2013 at 05:47 UTC | |
by rjt (Curate) on Aug 03, 2013 at 10:29 UTC | |
by Laurent_R (Canon) on Aug 03, 2013 at 09:41 UTC |
In Section
Seekers of Perl Wisdom