5

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 ...

I want some thing like this :

$pattern='/^[unicode chars without \'-_;?]*$/u'; 
if(!preg_match($pattern, $url))
   echo #error;
4

1 回答 1

10

字母的 Unicode 属性是\pL这样的preg_match

preg_match('/^\pL+$/u', $string);

对于网址,您可以添加数字\pN和点:

preg_match('/^[\pL\pN.]+/u', $string);
于 2012-05-28T17:14:59.103 回答