If you use zero-width assertions such as a look ahead or look behind then you'll never skip n number of items. You'll have to "eat" the characters so that processing will not include characters used for the previous match.
The expression below should do the trick. It matches two instances of a close bracket, not close bracket, close bracket before it matches the third close bracket, not close bracket, close bracket. To get the content inside the brackets, use Match.Groups
and GroupCollection.Captures
.
var re = new Regex(@"(?:(?:>[^<]+<.*?){2}>)([^<]+)(?:)");
var matches = re.Matches(@"<a>1</a><b>2</b><a>3</a><b>4</b><e>5</e><a>6</a>");
foreach (Match match in matches) {
Console.WriteLine(match.Groups[1].Captures[0]);
}
// output:
// 3
// 6
And yes, this will be a very bad html parser, but fine for a quick and dirty hack.