0

我希望我的模式允许:az(可以有重音)、AZ(可以有重音)、破折号、空格和点。这个模式应该用哪种方式编写?

实际模式:

array('name','match', 'not' => true, 'pattern' => '/[^a-zA-Z0-9-\s]/')
4

3 回答 3

1

试试下面的正则表达式,我认为这就是你要找的:

$str = 'hjkáÁdfgçÇhj.-hj'; // Matches your criteria
if(preg_match('/^[a-zA-ZÁ-ý\-\. ]+$/', $str))
    echo 'match';
else
    echo 'no match';
于 2013-03-02T17:33:30.873 回答
0

can you try this


array('name','match', 'not' => true, 'pattern' => ''^([a-zA-ZÁ-ý\-\. ]+)^'')

于 2013-03-03T21:05:28.277 回答
0

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)

于 2013-03-02T17:28:27.840 回答