I want to match all expressions with exactly one whitespace. Currently, I\'m using [^\\\\s]*\\\\s[^\\\\s]*. That doesn\'t seem like a very good way, though.
String[] ss = { " ", "abc", "a bc", "a b c d" };
Matcher m = Pattern.compile("^\\S*\\s\\S*$").matcher("");
for (String s : ss)
{
if (m.reset(s).matches())
{
System.out.printf("%n>>%s<< OK%n", s);
}
}