Reputation: 33684
I have the following regex that validates if it's a minimum of 3 words:
"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?
Upvotes: 1
Views: 1389
Reputation: 786289
The following regex should work:
^(?:(?:^| )\S+ *){3,}$
Upvotes: 1
Reputation: 8192
Does this do what you want?
/(\b\S+.*?){3,}/.test('How much is this?')
Upvotes: 0