Welcome to WebmasterWorld Guest from 184.108.40.206
Is there a way to replace text and have the expression ignore text in between hrefs - stripping html is not a solution unless you can put it back again, need to keep existing html intact.
$pattern = "#>([^<]*)$find([^<]*<(?!/a>))#is";
$Text = preg_replace($pattern,">$1<a href='someurl'>$find</a>$2",$Text,1);
The captured parts get used in the replacement value as variables $1 and $2.
The biggest trick going on here is that we are using a negative lookahead assertion. You can read more about these fun tricks in the PHP PCRE Pattern Syntax [php.net] manual pages.