how to add Arabic letters to url in regex
if (!preg_match("^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$^",$_POST['url'])) 开发者_运维问答{}
The best option is to use an Unicode chracter class for that. It would be \p{Arabic}
for your case. But don't forget that you should also add the Unicode PCRE modifier /u
at the end.
Replace [a-zA-Z0-9]
with [\pL0-9]
and don't forget the the Unicode PCRE modifier /u
at the end of your regex.
Using its UTF-8 code: \x123
should help.
UPD: the full regexp seems to be like this (for the rule any URL part could contain arabic chars
):
^(http|https|ftp)\://[a-zA-Z0-9\-\.\x0600-\x06FF\x0750-\x077F\xFB50-\xFDFF\xFE70-\xFEFF]+\.[a-zA-Z\x0600-\x06FF\x0750-\x077F\xFB50-\xFDFF\xFE70-\xFEFF]{2,3}(:[a-zA-Z0-9\x0600-\x06FF\x0750-\x077F\xFB50-\xFDFF\xFE70-\xFEFF]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~\x0600-\x06FF\x0750-\x077F\xFB50-\xFDFF\xFE70-\xFEFF])*$
精彩评论