$re = '/<a[^>]*href\s*=(?<HRef>[^>]+)>/';
$str = '<html><head>
<title>Simple</title>
</head>
<body>
<div id="Content" style="padding: 5px;">
<p><a href="http://confluence:8080/download/attachments/8618175/Text.txt?version=1&modificationDate=1484637732181">Text.txt</a><br/>
<span class="image-wrap" style=""><img src="http://confluence:8080/download/attachments/8618175/add-button-blue-hi.png?version=1&modificationDate=1484562338796" style="border: 1px solid black" /></span><br/>
<span class="image-wrap" style=""><a class="confluence-thumbnail-link 300x200" href=\'http://confluence:8080/download/attachments/8618175/attachment.jpg\'><img src="http://confluence:8080/download/thumbnails/8618175/attachment.jpg" style="border: 1px solid black" /></a></span></p>
</div>
</body></html>';
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