我希望我的模式允许:az(可以有重音)、AZ(可以有重音)、破折号、空格和点。这个模式应该用哪种方式编写?
实际模式:
array('name','match', 'not' => true, 'pattern' => '/[^a-zA-Z0-9-\s]/')
试试下面的正则表达式,我认为这就是你要找的:
$str = 'hjkáÁdfgçÇhj.-hj'; // Matches your criteria
if(preg_match('/^[a-zA-ZÁ-ý\-\. ]+$/', $str))
echo 'match';
else
echo 'no match';
can you try this
array('name','match', 'not' => true, 'pattern' => ''^([a-zA-ZÁ-ý\-\. ]+)^'')
The meaning of ^
inside []
is not so what you need is almost the same :-)
/[a-zA-ZÁ-ý0-9-\s]/u
to further elaborate what you might need is /^[a-zA-ZÁ-ý0-9-\s]+$/
which allows the whole string to be only of what's inside the []
and as many as you want (the +
is for as many characters as there are)