need a simply preg_match, which will find \"c.aspx\" (without quotes) in the content if it finds, it will return the whole url. As a example
$content = \'
You use DOM to parse HTML, not regex. You can use regex to parse the attribute value though.
Edit: updated example so it checks for c.aspx.
$content = '[4]New message
foo
';
$dom = new DOMDocument();
$dom->loadHTML($content);
$anchors = $dom->getElementsByTagName('a');
if ( count($anchors->length) > 0 ) {
foreach ( $anchors as $anchor ) {
if ( $anchor->hasAttribute('href') ) {
$link = $anchor->getAttribute('href');
if ( strpos( $link, 'c.aspx') ) {
echo $link;
}
}
}
}