PHP: Register> USERNAME with only Greek characters and only one space
1 answer
You want to use a modifier/u
so that the Unicode expression is known, and I prefer to use hex codes when specifying this kind of thing - it's hard to tell alpha (A) from ay (A).
According to Wikipedia , the "Greek and Coptic" Unicode block uses codes from 0x370 to 0x3ff:
function checkGreek($newusername) {
if (preg_match("/^[\x{370}-\x{3FF} ]{1,50}$/u", $newusername)) {
echo "It Greek to me";
} else {
echo "Non-Greek in there";
}
}
checkGreek("ΑΒ ΓΔ");
checkGreek("ΑΒ ΓΔ 123");
checkGreek("AB CD");
+1
source to share