$re = '/<li><a href=\"(?:(?!#sequence_only).)*\">(.*)</a>/m';
$str = ' <!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>';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php