I am going to build a multilingual website with PHP and need to have a preg_match which passes all Unicode characters and numbers.
i.e I need it to pass English letters, Spanish letters,Italian letters and as you may know I don't want to pass other characters like ' " _ - and ...
我打算用PHP构建一个多语言网站,需要有一个传递所有Unicode字符和数字的preg_match。即我需要它传递英文字母,西班牙文字母,意大利字母,你可能知道我不想传递其他字符,如'“_ - 和......
I want some thing like this :
我想要这样的事情:
$pattern='/^[unicode chars without \'-_;?]*$/u';
if(!preg_match($pattern, $url))
echo #error;
1 个解决方案
#1
7
Unicode property for letter is \pL
so in preg_match
:
字母的Unicode属性是\ pL所以在preg_match中:
preg_match('/^\pL+$/u', $string);
for an url you could add numbers \pN
and dot:
对于网址,您可以添加数字\ pN和点:
preg_match('/^[\pL\pN.]+/u', $string);
#1
7
Unicode property for letter is \pL
so in preg_match
:
字母的Unicode属性是\ pL所以在preg_match中:
preg_match('/^\pL+$/u', $string);
for an url you could add numbers \pN
and dot:
对于网址,您可以添加数字\ pN和点:
preg_match('/^[\pL\pN.]+/u', $string);