I'm trying to make a regex in Java that does not match excessive whitespaces between words, and whitespaces at the beginning and end.
I have done this regex so far
^[\\S].*[\\S]$
That fail when there are whitespaces at the beginning and end of a line
But how about excessive whitespaces between words?
I want this line to fail:
"test test"
But not this:
"test test"
I tried this:
^[\\S].*(?![\\s]{2,}).*[\\S]$
But it didn't work.