I'm trying to validate a string using /[\p{L}\s]{6,}/
and trying to match characters only (Unicode ones as well). I used regex101 to test my regex and it works for the string Владимир Алексић
.
However, when I use that regex in preg_match()
with the same string, it always returns 0
. Yet, it returns 1 if I avoid all characters except A-Za-z
.
Why is that so?
The \p
and other escape sequences which work with unicode character properties don't work unless the u
pattern modifier is set.
/[\p{L}\s]{6,}/u