Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- need help with preg replace


darkage - 8:38 pm on Dec 26, 2008 (gmt 0)


thanks coopster, that got me going in the right direction.

I modified it a bit, so it's ungreedy as well as won't match words that are already contained in html:

$patterns[0] = "/(<p>[^<]*\b)(hello)(\b[^>]*<\/p>)/isU";

So it will match
<p>Hello there</p>
but not


<p><a href="/">Hello</a> there</p>

or


<p><table class="hello"><tr>...</tr></table> there</p>

[edited by: eelixduppy at 6:38 am (utc) on Dec. 27, 2008]
[edit reason] disabled smileys [/edit]


Thread source:: http://www.webmasterworld.com/php/3814557.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com