using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<li><a href=\""(?:(?!#sequence_only).)*\"">(.*)</a>";
string input = @" <!DOCTYPE html>
<!-- The following setting enables collapsible lists -->
<p>
<a href=""#human"">Human</a></p>
<p class=""collapse-section"">
<a class=""collapsed collapse-toggle"" data-toggle=""collapse""
href=#mammals>Mammals</a>
<div class=""collapse"" id=""mammals"">
<ul>
<li><a href=""#alpaca"">Alpaca</a>
<li><a href=""#armadillo"">Armadillo</a>
<li><a href=""#sequence_only"">Armadillo</a> (sequence only)
<li><a href=""#baboon"">Baboon</a>
<li><a href=""#bison"">Bison</a>
<li><a href=""#bonobo"">Bonobo</a>
<li><a href=""#brown_kiwi"">Brown kiwi</a>
<li><a href=""#bushbaby"">Bushbaby</a>
<li><a href=""#sequence_only"">Bushbaby</a> (sequence only)
<li><a href=""#cat"">Cat</a>
<li><a href=""#chimp"">Chimpanzee</a>
<li><a href=""#chinese_hamster"">Chinese hamster</a>
<li><a href=""#chinese_pangolin"">Chinese pangolin</a>
<li><a href=""#cow"">Cow</a>
<li><a href=""#crab-eating_macaque"">Crab-eating_macaque</a>
<div class=""gbFooterCopyright"">
© 2017 The Regents of the University of California. All
Rights Reserved.
<br>
<a href=""https://genome.ucsc.edu/conditions.html"">Conditions of
Use</a>
</div>";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx