Suppose I have a string containing the following anchors, among other content:
<a href="foo.html" class="foo">Foo</a>
<a href="bar.html" class="excludeMe">Bar</a>
<a href="baz.html" class="baz">Baz</a>
Now I need a regex for matching all anchors that DO NOT have the class "excludeMe". The anchors can have any number of attributes in addition to href and class, and they are not necessarily in a fixed order. But the anchors that have the "excludeMe" class, will only have that single class. I have the following pattern for matching all anchors:
@"(<a.*?>.*?</a>)"
Now I need to expand it so the anchors with "excludeMe" class are not matched. I've tried using negative lookahead to achieve this, but it seems I'm unable to get it right. Either all anchors, no anchors, or content after the anchors is matched.
Any suggestions on how to do it?
Thanks!