almaric has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
just a quick question. Short scan over a few regexp tutorials didn't lead me to an answer.
outputs:$a="aaaa"; @a=$a=~m/aa/g; print join ( "-", @a );
But with another pov one could find 3 occurences of 'aa' in 'aaaa' but I think this is a question of how matching is defined in perl.aa-aa
Is there a way to manipulate the regexp above to match 3 times in the given string or do I have to write my own sub for this task?
Any suggestion to do this the "perl way"?
Thanks!
PS: A friend came up with the following, non-experimental :) suggestion
Greetings$regexp="a{2}"; $a="aaaa"; @a=$a=~m/(?=($regexp))./g; print join ( "-", @a );
Back to
Seekers of Perl Wisdom