in reply to Incorrect pattern recognition problem.

I consider it a bug, though a design bug. I explain how I would improve this in Re^3: zero-length match increments pos() (two!), but you'll probably have to read more of zero-length match increments pos() to understand what I'm talking about (which will also get you a good explanation of how Perl decides which surprising results to return).

It boils down to the fact that Perl's regex engine is forced to not return certain matches else it'd cause infinite loops. But the least-surprise choice skips a few more matches (only when zero-width matches are possible) and that choice is what 'sed' and 'vi' both return but not what Perl does.

- tye        

  • Comment on Re: Incorrect pattern recognition problem. (bug)