[Solved] regex with php pattern [closed]


Can try using this pattern

$str="<h3 class="r"><a href="https://stackoverflow.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0CCUQFjAA&amp;url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F18682352%2Fgoogle-search-results-with-php&amp;ei=9ptsVNivF_iTsQTv-YJ4&amp;usg=AFQjCNFdoi58ua_4oBtPM4LHybHRZVF9jQ&amp;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]