Since PHP 5.2.x it may happen to find unexpected empty output on regular expressions (preg_replace, preg_match, etc...) when parsing very long strings. This bug is caused by a restrictive limit of pcre.backtrack_limit directive. The default value is 100000, so it can handle strings up to 100000 characters. It would make more sense to change the limit to a higher value, even 20MB. The same change can be applied to the pcre.recursion_limit directive.
Both directives can be changed in the php.ini file:
pcre.backtrack_limit=20971520
pcre.recursion_limit=20971520
or by ini_set():
ini_set('pcre.backtrack_limit', 20971520);
ini_set('pcre.recursion_limit', 20971520);
