|Welcome to the Monastery|
Re: You won't believe what this regular expression does!by LanX (Sage)
|on Feb 25, 2021 at 13:01 UTC||Need Help??|
Lets dissect this into smaller problems.
I tried to simplify the case to avoid misunderstandings
Surprise: the o is replaced twice.
Explanation so far
You and Hauke already explained that
(And I agree that the referenced perlre#Repeated-Patterns-Matching-a-Zero-length-Substring needs a rewrite)
Now, why is it surprising?
I think your case is that $ in combination with the /m modifier should act differently. Correct?
Here a guess for the last question
Question @all: Is the problem better understood now? :)
added more code
added headlines for structuring
°) because empty patterns are always matching