in reply to Re^2: Non-greedy substitution
in thread Non-greedy substitution

The regex engine prioritizes "leftmost". So it will always find the left most place the entire regex will match.

Replies are listed 'Best First'.
Re^4: Non-greedy substitution
by ikegami (Patriarch) on Nov 15, 2024 at 20:14 UTC

    That's wrong.

    That's the same mindset as saying .*? prioritizes shortest. But we all know that mindset is flawed, since that's the issue at hand.

    For example, your explanation doesn't work for \G(?s:.)*?\K,(.+?)$, which is the OP's pattern with the implicit bits made explicit.