In Python’s implementation of regular expressions you can do the following:
<(?P<foo>.*)>(.*)</(?P=foo)>
and basically it will look for <this>right here</this> but not <this>right </here>. Basically it allows you to use the previously captured named match later in your regex. Is there a way to do this with .NET’s Regex?
You can use sharp brackets or single quotes and use \k to reference them:
or
See this page for more info and scroll down to the “Named Capture with .NET’s System.Text.RegularExpressions” section.