There have been a number of posts and replies for 'killer' reasons for lookaround (starting with Darren's query), and I want to drop a few thoughts into the fray.
1. To do the work of multiple regexes, but within a single regex. Michael Ash and Justin both hinted at this, demonstrating if not explicitly calling it out as such. A fine example of this would seem to be a password validation regex, such as “verify at least 8 characters, and includes at least one digit, one letter, and one symbol”. Use lookaround to test each independent and possibly overlapping requirement. The length requirement needs to look at every single character, so it overlaps with each other requirement; the one-character requirements overlap with each other because they may appear in any order.
One way:
(?=.*\d)(?=.*[a-z])(?=.*[!@#$%]).*{8,}
Alas, this isn't a 'killer' reason and I concede it is possible to compose an equivalent pattern without the use of lookahead, but it would be insane.
2. To force a lazy match to occur. Michael Ash hinted at this in his mention of entity-replacement. Given input like:
<tag1> lorem ipsum <a href=a>alpha</a> <a href=b>beta</a>
<tag2> lorem ipsum <a href=z>zed</a> <a href=y>why</a>
where the number of links may vary, zero or more. Acquire the text of each link, but only of the set of links that follow the <tag>.
Here's the pattern I used:
<tag(?'tag'\d) .*? (?=<a|<tag) (<a[^>]*> ('text'[^<]*) </a>)*
RegexOptions.Singleline, IgnorePatternWhitespace, ExplicitCapture
Is there an assertionless way?
-Wayne