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.
在 .net MVC 应用程序中,我需要正则表达式来验证输入中的至少两个单词,并且输入的最小长度应该大于 5。(允许的特殊字符只有“。”并且不允许使用数字)
目前我正在使用
^([a-zA-Z\.\s]{5,})+$.
两个字都行不通。
听起来你可能需要类似的东西:
^[a-zA-Z\.]{6,} [a-zA-Z]{6,} .+$
这将根据您的规范匹配 2 个单词,然后允许字符数量。
如果输入的总长度应大于 5: "^([a-zA-Z.\\s]{6,})$"- 它对我来说很好。
"^([a-zA-Z.\\s]{6,})$"
如果每个单词的长度应大于 5: "^([a-zA-Z]{6,}[\\s.]*)++$"
"^([a-zA-Z]{6,}[\\s.]*)++$"