通过类名regex和php获取href值[复制]

This question already has an answer here:

i need to get href value from class name like that.

some one can give me regex to find this class name and get from there the href ?

<a href='http://www.tovtoda.co.il/BusinessPage.aspx?b=6973' class="boldOrange"></a>

thanks alot

</div>

You can do this using DomDocument and XPath, see here

$str = '<a href="http://www.tovtoda.co.il/BusinessPage.aspx?b=6973" class="boldOrange"></a>';

$doc = new DOMDocument();
$doc->loadHTML($str);
$xpath = new DOMXPath($d);
$links = $xpath->query('//a[@class="boldOrange"]');

foreach ($links as $link) {
    $url = $link->getAttribute('href');
    print $url . PHP_EOL;
}