Reputation: 3085
I tried to write a regex for validating following string, good <3 spaces> morning
The regex I tried was \s{2,}. However the regex match failed
Upvotes: 0
Views: 121
Reputation: 39951
The string must match entirly
"Good morning".matches(".*\\s{2}.*");
Upvotes: 2
Reputation: 4320
How about "\Agood morning\Z"?
It might seem too obvious, but it works.
Upvotes: 0
Reputation: 3742
".*\s\s.*"
Upvotes: -1