preg_match limit
One thing to note when working with larger texts and preg_replace() is that the matched text cannot be longer than (usually) 100 000.
I discovered this while debugging a CMS-system which wouldn’t display a certain text. Took forever to find the problem.
Thankfully the default values can be changed – but only if you have access to the server.
http://us.php.net/manual/en/pcre.configuration.php