如何在网址正则表达式中添加阿拉伯字母 [英] how to add Arabic letters to url regex
本文介绍了如何在网址正则表达式中添加阿拉伯字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在正则表达式的网址中添加阿拉伯字母
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'])) {}
推荐答案
最好的选择是使用 Unicode chracter类.对于您的情况,它将为\p{Arabic}
.但是不要忘记,您还应该在末尾添加Unicode PCRE修饰符/u
.
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.
这篇关于如何在网址正则表达式中添加阿拉伯字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文