View Full Version : preg_replace not sure what the correct expression is

09-21-2009, 02:57 PM
Hi all

I need to scan a block of body copy that will replace certain words within the copy with other words.

I can do this is and got this part working.

How ever i need it to replace only words out side of any html tags. <.*> </.*> < />

So if the word appears in a link its ignored.

Any ideas on how to do this?

my code so far

PHP Code:

$patterns[] = '/'.$tag.'(?![^<]*>)/i';
$replacements[] = '<a href="'/'.$tag.'">'.$tag.'</a>';