note
kvale
In example 3, the lookahead assertion doesn't match at the beginning of the string, so the regex tries to match at the next position in the string, that fails and so on. This continues until the regex matches at position "oo then..." in which case no foo is found and it succeeds.
<p>
In example 4, the .* will first eat the whole string and then the foo will fail to match, satisfying the negative assertion :). So the whole string is printed.
<p>
Both of these examples show the danger of creating nonlocal assertions. It is easy to do something unexpected when the string tested is some distance from the assertion.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-145001">
<p>
-Mark
</div></div>
549538
549538