Amb*_*ber 21
/^[a-zàâçéèêëîïôûùüÿñæœ .-]*$/i
Run Code Online (Sandbox Code Playgroud)
使用/i不区分大小写使事情变得更简单.如果您不想允许空字符串,请更改*为+.
简化解决方案:
/^[a-zA-ZÀ-ÿ-. ]*$/
说明:
^ Start of the string
[ ... ]* Zero or more of the following:
a-z lowercase alphabets
A-Z Uppercase alphabets
À-ÿ Accepts lowercase and uppercase characters including letters with an umlaut
- dashes
. periods
spaces
$ End of the string
尝试:
/^[\p{L}-. ]*$/u
Run Code Online (Sandbox Code Playgroud)
这说:
^ Start of the string
[ ... ]* Zero or more of the following:
\p{L} Unicode letter characters
- dashes
. periods
spaces
$ End of the string
/u Enable Unicode mode in PHP
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21584 次 |
| 最近记录: |