--- In [email protected], Julien Pierrehumbert <[EMAIL PROTECTED]> 
wrote:
>
> Is it really? This is indeed the intuitive result but look at what's
> happening:
> 
> -we have a match at the first empty lines and the following two
> characters are consumed to prevent an infinte loop.
> 
> -we have a zero-character match at the second empty line but this time
> the following two characters are not consumed because we are in no
> danger of falling in an infinite loop as characters have already been
> consumed before the match (I could change that... what do other regex
> implementations do?)
> 
> -we have a match at the second empty line... as it happens, the match
> happens at the same position as the previous one but this time the
> following two characters are deleted to prevent an infinite loop
> 
> -the last empty line doesn't match because the plugin doesn't even try
> as the string has now been fully consumed (is that yet another bug?)
> 
> I hope I got it right... I don't want to debug the process step by step
> right now.
>

Good explanation. It revealed well the evil nature of the empty match
and how hard to work-around it in a natural manner. Moreover, how bad
decision was choosing not-single-byte as a newline.

BTW, I'm not sure why the following two output different results:

esc(?"\r\nGoodbye\r\n\r\n",?"\").replaceg(?"(?m)^\R", ?"Hello\0")
esc(?"\r\nGoodbye\r\n\r\n",?"\").replaceg(?"(?m)(?<=^)\R", ?"Hello\0")

Sean

Reply via email to