Can try using this pattern
$str="<h3 class="r"><a href="https://stackoverflow.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCUQFjAA&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18682352%2Fgoogle-search-results-with-php&ei=9ptsVNivF_iTsQTv-YJ4&usg=AFQjCNFdoi58ua_4oBtPM4LHybHRZVF9jQ&bvm=bv.80120444,d.cWc" onmousedown="return rwt(this,\"\',\'\',\'\',\'1\',\'AFQjCNFdoi58ua_4oBtPM4LHybHRZVF9jQ\',\'\',\'0CCUQFjAA\',\'\',\'\',event)" data-href="http://stackoverflow.com/questions/18682352/google-search-results-with-php">curl - Google search results with php - Stack Overflow</a></h3>';
$re="/data-href=["\"]?([^"\' ]*)["\' ]/is';
preg_match($re, $str, $m);
$attr_value = trim(str_replace('data-href=", "', $m[0]), '"');
echo $attr_value;
Output:
http://stackoverflow.com/questions/18682352/google-search-results-with-php
solved regex with php pattern [closed]