Your first and last RE match zero-to-many characters from the end of the last match to the end of the line. So, first it matches "The quick" and puts its mark at the end of that. Next, it starts after "The quick"-- at the end of the line-- and looks for zero or more characters. Since the mark is at the end of the line, that matches, so you get the empty match. Zero equals zero. :) Ditto for after "brown fox" and "jumped." '$' matches the end of the string as well as the end of the line.
Your second pattern forces the match to begin at the beginning of a line, so the secondary matches can't happen.
I suspect that having the zero-length patterns match once and only once in a global search is a compromise between sanity-- those ARE valid matches, after all-- and insanity. After all, if zero-length patterns matched more than once in a global search, any zero-length pattern would turn a global match into an infinite loop. A zero-length match can't, by definition, advance the mark, so it would also match the next time, and the next, etc.
stephen
In reply to Re: Re: Bother (Re: Re: Split and empty strings)
by stephen
in thread Split and empty strings
by andye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |