PHP:允许字母,数字和阿拉伯字符

时间:2017-03-26 06:31:20

标签: php arabic

如何在preg_match中允许阿拉伯字符?

if(!preg_match("/^[a-zA-Z0-9]+$/", "لحمدلله")) {
    echo "Firstname can only use letters, numbers and arabic characters.";
}

1 个答案:

答案 0 :(得分:3)

你可以用这个:

if(!preg_match("/^[\p{Arabic}a-zA-Z0-9]+$/u", "لحمدلله")) {
    echo "Firstname can only use letters, numbers and arabic characters.";
}