perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
I used an RE of the form:
(text);(?:(float)[non-num]){4}
This matches as expected, but I'm only getting 2 substring matches instead of getting back the 5 desired substrings. $1 is the text field, but $2 is filled with the final float substring with strings 1-3 being tossed. This isn't desirable.
I could duplicate the sub-RE that has the {4} count tag, 4 times, but that seems wasteful and less clear. Is there a way to preserve my idea matching "4"-sub-RE's while also returning the 1st 3 matches?
Seems like such a simple concept...sigh. Is this doable without nibbling at the line in a loop that picks off the trailing numerics with successive search & replace operations? TIA -l
2006-02-18 Retitled by planetscape, as per Monastery guidelines
Original title: 'simple question ?'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: capturing multiple repeated regex subparts
by ikegami (Patriarch) on Feb 17, 2006 at 21:01 UTC | |
by japhy (Canon) on Feb 17, 2006 at 21:18 UTC | |
|
Re: capturing multiple repeated regex subparts
by Roy Johnson (Monsignor) on Feb 17, 2006 at 20:57 UTC | |
|
Re: capturing multiple repeated regex subparts
by GrandFather (Saint) on Feb 17, 2006 at 20:55 UTC | |
|
Re: capturing multiple repeated regex subparts
by kwaping (Priest) on Feb 18, 2006 at 00:01 UTC | |
|
Re: capturing multiple repeated regex subparts
by neilwatson (Priest) on Feb 17, 2006 at 20:49 UTC | |
|
Re: capturing multiple repeated regex subparts
by Aristotle (Chancellor) on Feb 20, 2006 at 03:44 UTC |