SamCG has asked for the wisdom of the Perl Monks concerning the following question:
but, what if I don't want the position to set to after the last match, but to one character after the beginning of the last match to produce ab,bc,cd,de,ef,fg? I've tried a few strange variants of adding code into the expression to alter the 'abcdefg' midway, but these don't seem to produce the results I want.perl -e "@re='abcdefg'=~/(..)/g;print join ',', @re;" #prints ab,cd,ef
No particular purpose here other than just to wield regexes better, so if there are practical reasons this is ludicrous feel free to tell me.perl -e "$_='abcdefg';@re=/(..)(?{reverse;chop;reverse;})/g;print join + ',', @re;" ab,cd, perl -e "$_='abcdefg';@re=/(..)(?{$_=substr($_,1)})/g;print join ',', +@re;" bc,ef,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex match iterative grouping
by Ido (Hermit) on Apr 06, 2006 at 16:35 UTC | |
|
Re: Regex match iterative grouping
by sfink (Deacon) on Apr 06, 2006 at 17:10 UTC | |
by SamCG (Hermit) on Apr 06, 2006 at 19:39 UTC |