$re = '/https:\/\/tld\.example\.com(.*?)ref=testetghe/';
$str = 'icon-459822882 attributeIcon-1499443538" focusable="false" height="100%" role="img"
width="100%"><use xlink:href="#icon-clipboard"></use></svg><dl class="itemAttribute-1164924913"><dd
class="attributeValue-3783238563"><a class="attributeLink-387024144" rel=" noopener noreferrer"
href="https://tld.example.com/en/main?id=325235231763265&ref=testetghe"
title="Opens in a new window." target="_blank';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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