public static String replaceSpacesWithDelimiter(String content,
      String delimiter) {
    List<String> parts = new ArrayList<String>();
    Matcher m = Pattern.compile("([^\"]\\S*|\".+?\")\\s*").matcher(content);
    while (m.find()) {
      String part = m.group(1);
      if(part.startsWith("\"") && part.endsWith("\"")) {
        part = part.replaceAll("^\"|\"$", "");
      }
      parts.add(part);
    }
    return String.join(delimiter, parts);
  }
@Test
  public void testReplaceSpacesWithDelimiter() {
    String command = "ls  -l \" space\"";
    String expected = "ls,-l, space";
    String actual = ProviderUtils.replaceSpacesWithDelimiter(command, ",");
    Assert.assertEquals("replaceSpaceWithDelimiter produces unexpected result.",
        expected, actual);
  }