Regular expression problem
| From: | Stuart | Date: | Fri, 01 Nov 2002 19:04:16 +0000 |
| Subject: | Regular expression problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122443@lists.php.net to get a copy of this message | ||
I just moved some *working* code from a Win2k server running PHP 4.2.1 to a FreeBSD server running 4.2.3 and the following code no longer works...
$templatetext = preg_replace("/<!-- include\(\"([[:ascii:]]+?)\"\) -->/e", "g_includecallback(\"\\1\")", $templatetext);
if (!preg_match("/([[:ascii:]]+?)<!-- begin set -->([[:ascii:]]+?)<!-- end set -->([[:ascii:]]+?)$/i", $templatetext, $matches))
{
// Report the error and stop processing the page
g_Halt("Could not find set definition in set list template: $g_setlisttemplate");
}
The first line that processes includes works and after that line $templatetext contains the full template with the include statements replaced with the contents of the file. After the preg_match statement has run (and succeeded), $matches[0] should contain the same as $templatetext did after the previous line. However, this is not the case. A sizable chunk of the text at the start of the variable has been lost and I cannot figure out why. Can anyone give me any pointers?
Thanks.
--
Stuart