[英]javascript regular expression of minimum 3 words and allow special characters
I have the following regex that validates if it's a minimum of 3 words: 我有以下正则表达式可验证是否至少3个单词:
"minimumThreeWordsAndNoURL": {
"regex": /^(\b\w+\b\s?){3,}$/,
"alertText": "Too short"
},
Now the issue is that when I do 'How much is this?' 现在的问题是,当我执行“这是多少?” it fails because of the special characters. 由于特殊字符而失败。 How do I allow special characters in this regex? 如何在此正则表达式中允许特殊字符?
这是您想要的吗?
/(\b\S+.*?){3,}/.test('How much is this?')
试试这个未经测试的:
(\b.{3,}\b\s)+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.