in reply to Regex match iterative grouping
perl -le '$_ = "abcd"; while (/(..)/g) { print $1; --pos }'
Or closer to your exact question:
You might be able to do that in a list-context match with an embedded expression, but that would be too scary for me.perl -le '$_ = "abcdefg"; while (/(...)/g) { print $1; pos($_) -= leng +th($1); pos($_)++ }'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex match iterative grouping
by SamCG (Hermit) on Apr 06, 2006 at 19:39 UTC |