Question

When using preg_match('/^[\w-]+$/u', $value) my development server (5.3.15) returns true for umlaut words. My live server (5.3.2-1ubuntu4.19) returns false.

What do I have to do to make the live server behave the same way as my development server? (Unfortunately, I cannot simply update the php version.)

The code is exactly the same on both machines. Both serve pages as UTF8.

Was it helpful?

Solution

\w is defined to be [A-Za-z0-9_] iirc.

try preg_match('/^[\pL-]+$/u', $value) instead.

http://php.net/manual/en/regexp.reference.unicode.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top