Strange PHP UTF-8 Behaviour
Shouldn't it be
$text = preg_replace('#[^\pL\d]+#u', '-', $text);
in line 6. If you escape the \
you'll have a literal \
in your exclusion class. So the regex [^\\pL\d]+
finds one or more occurrences of a character not being a \
, p
, L
or a digit. This would explain why "Développeur Web"
will be reduced to "-pp-"
- everything up to the first p
matches and will be replaced by a -
; the same is true for everything after the second p
.
Perhaps there is a difference between both machines in how an escaped \
is treated.
EDIT after OP comment:
Actually escaping the \
is no problem here - both versions are treated the same way. What actually seems to be the problem ist, that the used PCRE version does not support unicode properties and wasn't compiled with --enable-unicode-properties
.