views:

67

answers:

2

Dear all,

several months ago, you provided a perfect solution for my IsAlpha & co issues. But once again, I ran into issues after upgrading PHP (to version 5.2.9), although the ctype_* functions seem to do their job now:

ctype_alpha( $value ) /* VS */ preg_match("/^[\p{L} _.\-]+$/u",    $value)

ctype_alnum( $value ) /* VS */ preg_match("/^[\p{L}0-9 _.\-]+$/u", $value)

By issues, I mean that 'GB' or 'blablue' is i.e. correctly identified as alpha by ctype_alpha(), but fails with preg_match("/^[\p{L} _.\-]+$/u", $value).

Please let me know if you have any ideas, I ran out of them after some serious googling..

Many, many thanks!

P.S. LANG/LC_CTYPE/etc is set to en_US.UTF-8 both on both environments

A: 

I had some issue with a regex using unicode metacharacters on a hosting server. Issue in short: it doesn't work. I didn't investigate on the true cause since it was a temporary server, but you might look into unicode support as your problem seems similar.

kemp
Please let me know if you mean by unicode the locale setting of the user running Apache/PHP or something else. Many thanks!
MrG
+2  A: 

Make sure PCRE has been compiled with UTF-8 support as well as Unicode property support.

if ( ! @preg_match('/^.$/u', 'ñ'))
    echo 'PCRE has not been compiled with UTF-8 support.';

if ( ! @preg_match('/^\pL$/u', 'ñ'))
    echo 'PCRE has not been compiled with Unicode property support.';

Checks from http://github.com/kohana/kohana/blob/master/install.php.

Geert