Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种方便的方法来检查 PHP 中 preg_match 中的字母和空格。
所以你只能添加“荷兰”或“丹麦”
提前致谢!
preg_match('/^[a-zA-Z\s]+$/', $string);
^和$分别表示字符串的开头和结尾,a-z是小写字母,A-Z是大写字母,\s是空格,+表示 1 次或多次。
^
$
a-z
A-Z
\s
+