Mad*_*ams 5 php regex encoding
我在 php 中使用 preg_match 时遇到问题。
\n我希望我的用户仅使用有效字符填写“名称”字段。\n例如:不要使用数字或特殊字符。
\n我的网站最终将是双语的,但我的大多数访问者都是法裔加拿大人
\n我更喜欢 utf-8 作为编码。\n所以在我的文档顶部有这个标签:
\n<meta charset="utf-8" />\nRun Code Online (Sandbox Code Playgroud)\n我需要接受表单中的重音字符,我已经尝试过:
\n(preg_match('/^\\p{L}+$/ui',$string))\nRun Code Online (Sandbox Code Playgroud)\n但我无法以这种方式接受口音。
\n以下是名称可以包含的字符的示例
\n\n\n让-弗兰\xc3\xa7ois d'abigu\xc3\xa4el
\n
这几乎是最糟糕的了
\n似乎每个人都在(preg_match('/^\\p{L}+$/ui',$string))工作,但我除外。
我需要这样的东西:
\n/^\\p{L}(\\p{L}+[- ']?)*\\p{L}$/ui\nRun Code Online (Sandbox Code Playgroud)\n但我需要让它发挥作用。
\n我的服务器是 IIS (godaddy)\nPHP 版本是 5.4\n默认时区设置为 America/Montreal
\n谢谢你!
\n这种模式应该有效:
/^\pL+(?>[- ']\pL+)*$/u
Run Code Online (Sandbox Code Playgroud)
但请随意将其改编为更奇特的名称(例如带有尾部引号或撇号的名称)。
| 归档时间: |
|
| 查看次数: |
4725 次 |
| 最近记录: |