Regular expression


$link_text = 'Apply now';
								
$content = '<td align="right" class="apply">   <a href="http://domain.com?h=AJ&cm=Details_ApplyNow" onClick="ApplyNowClick(\\'A7C6NP\\');" title="Apply for this now!">Apply Now</a></td>';
				

$pattern = '|<a[^>]+>('.$link_text.')</[^>]+>|U';   
preg_match($pattern, $content, $output); 

				
$pattern = '/<[a]{1}(.*)?>(.*)<\\/[a]{1}>/';  
$content = trim(preg_replace($pattern, '$1', $output[0])); 

... // then parse $content to get the href url

Is it possible to know what is wrong with the regular expression to get the href of this tag?
<td align=“right” class=“apply”> <a href=“http://domain.com?h=AJ&cm=Details_ApplyNow” onClick=“ApplyNowClick(\‘A7C6NP\’);” title=“Apply for this now!”>Apply Now</a></td>

Not getting anything in $output. I’ve this code working for a similar <a …> tag.

Thanks!

This regex

'/<a[^>]+>(Apply now)<\\/a>/i'

returns this

Array
(
    [0] => <a href="http://domain.com?h=AJ&cm=Details_ApplyNow" onClick="ApplyNowClick(\\'A7C6NP\\');" title="Apply for this now!">Apply Now</a>
    [1] => Apply Now
)

Doesn’t look very useful to me.
What is it you want to achieve with this code?

If you need only the href, try the following pattern

$pattern = '#href="([^"]+)"#i';