I would really appreciate some help with Java code to split the following inputs:
word1 key="value with space" word3 -> [ "word1", "key=\"value with space\"", "word3" ]
word1 "word2 with space" word3 -> [ "word1", "word2 with space", "word3" ]
word1 word2 word3 -> [ "word1" , "word2", "word3" ]
The first sample input is the tough one. The second word has quotes in the middle of the string not at the beginning. I found several ways of dealing with the middle example such as described in Split string on spaces in Java, except if between quotes (i.e. treat \"hello world\" as one token)