bradgrafelman wrote:What's your pattern look like? I suspect you're doing something like "(.)" in between the quotes in the HTML tag. You might need to make that expression non-greedy, by adding a question mark (i.e. "(.?)").
I figured I would first erase the link that displays in the html page since I don't need it at all and then extracting the url from the href later
like this works pretty well if the link that's displayed has no whitespaces
$str = preg_replace("/>\S+<\/a>/i", ">", $str);
but often there are whitespaces in the link like "<a href="google.com">go to google</a>" so I tried this, but it causes the problem I mentioned
$str = preg_replace("/>.+<\/a>/i", ">", $str);
as per your suggestion I changed to this and now it works the way I expect
$str = preg_replace("/>.+?<\/a>/i", ">", $str);
seems that I haven't studied the whole ungreedy concept enough yet, thanks for your help! when I get the URL extracted then I'll post all the code here and mark it resolved