This regex achieves the split for you, and cleans up any delimiting quotes:
String[] terms = input.split("\"?( |$)(?=(([^\"]*\"){2})*[^\"]*$)\"?");
It works by splitting on a space, but only if it is followed by an even number of quotes.
The quotes themselves are consumed, so they don't end up in the output, by including them optionally in the split term.
The term ( |$)
was needed to capture the trailing quote.
Note that if the first term could be quoted, you'll need to clean up that leading quote first:
String[] terms = input.replaceAll("^\"", "").split("\"?( |$)(?=(([^\"]*\"){2})*[^\"]*$)\"?");
Test code:
String input = "software term \"on the fly\" and \"synchron\"";
String[] terms = input.split("\"?( |$)(?=(([^\"]*\"){2})*[^\"]*$)\"?");
System.out.println(Arrays.toString(terms));
Output:
[software, term, on the fly, and, synchron]