pat_mc has asked for the wisdom of the Perl Monks concerning the following question:
Why am I only getting one match instead of two? I was expecting two matches, the first one in position 0 and the second one in position 1. Clearly, the regex engine continues matching at the end of the first match. Is there an elegant way (e.g., a regex modifier) to change the matching behaviour? Or do I really need to resort to the manual manipulation of the regex-internal matching position record?$ perl -e 'while('aaa' =~/(aa)/g){print $-[-1], "\n"}' 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Controlling matching position in regexes to match all proper substrings
by roboticus (Chancellor) on Oct 04, 2014 at 14:01 UTC | |
|
Re: Controlling matching position in regexes to match all proper substrings
by AnomalousMonk (Archbishop) on Oct 04, 2014 at 16:20 UTC | |
|
Re: Controlling matching position in regexes to match all proper substrings
by AnomalousMonk (Archbishop) on Oct 04, 2014 at 17:16 UTC | |
|
Re: Controlling matching position in regexes to match all proper substrings
by LanX (Saint) on Oct 04, 2014 at 14:00 UTC | |
by LanX (Saint) on Oct 04, 2014 at 14:25 UTC |