in reply to Re^2: Grab "as many occurrences as there are" in a long string
in thread Grab "as many occurrences as there are" in a long string
I was thinking about the “greedy” modifier, and how one would need to use this to avoid simply matching the entire string in a case like the one you have cited.Ah, you mean as in "something equals /.*?/"? Then here's a question for you. How many times does "FOO.*?BAR" occur in "zero FOO one FOO two BAR three BAR four"?
Where can I perldoc to read more about such Higher Magick, that I may one day Impress My Friends, too?Except for say, all will be revealed by reading man perlre. (Oh, and if you replace "(*FAIL)" with "(?!)", you could have done the trick ever since 5.005 - it's not something from this century).
Note also that
and/(FOO.*?BAR)(??{ say $1 })(*FAIL)/;
print exactly the same matches, although in a possible different order./(FOO.*BAR)(??{ say $1 })(*FAIL)/;
|
|---|