Try ~<a href="(.(?!remedy))*?".*?>(.*?)</a>~i
To the question, what you are doing wrong: Regexes match ever if anyhow possible and for each url (even that containing remedy
) it is possible to match '~<a href=".*?(?!remedy).*?".*?>(.*?)</a>~i'
because you did not specify remedy
may not be contained anywhere in the attribute but you specified there must be anything/nothing (.*?
) that is not followed by remedy
and that is the case for any url except those that begin with exactly <a href="remedy"
. Hope one can understand that...