PHP PCRE differences on testing and hosting servers
        Posted  
        
            by Gary Pearman
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Gary Pearman
        
        
        
        Published on 2010-04-23T17:25:57Z
        Indexed on 
            2010/04/24
            5:13 UTC
        
        
        Read the original article
        Hit count: 555
        
Hi all,
I've got the following regular expression that works fine on my testing server, but just returns an empty string on my hosted server.
$text = preg_replace('~[^\\pL\d]+~u', $use, $text);
Now I'm pretty sure this comes down to the hosting server version of PCRE not being compiled with Unicode property support enabled. The differences in the two versions are as follows:
My server:
PCRE version 7.8 2008-09-05
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack
Hosting server:
PCRE version 4.5 01-December-2003
Compiled with
UTF-8 support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Match recursion uses stack
Also note that the version on the hosting server (the same version PHP is compiled against) is pretty old.
What confuses me though, is that pcretest fails on both servers from the command line with
re> ~[^\\pL\d]+~u
** Unknown option 'u'
although this regexp works fine when run from PHP on my server.
So, I guess my questions are does the regular expression fail on the hosting server because of the lack of Unicode properties? Or is there something else that I'm missing?
Thanks all, Gaz.
© Stack Overflow or respective owner