in reply to Re^2: How can I access the number of repititions in a regex?
in thread How can I access the number of repititions in a regex?

There is such possibility, but using 'highly experimental' :) code:

$_='this is some text(55). this is another text. there are 2 texts.'; @re=/text(?{$cnt1++})|\d+(?{$cnt2++})/g; print "'text' occured $cnt1 times\n"; print "'\\d+' occured $cnt2 times\n";

But there are some problems: what if one of your regexps is part of another one?

Replies are listed 'Best First'.
Re^4: How can I access the number of repititions in a regex?
by pat_mc (Pilgrim) on Dec 18, 2008 at 15:15 UTC
    Good stuff, grizley!

    Thanks for throwing code evaluation expressions into the race ... they offer exactly the range of flexibility I need to solve my class of problems ... and - as you can tell by the date on this post - it took me quite some time to realise (a) what they are and (b) how they work.

    Your help is much apprecicated!

    Best regards -

    Pat