List of utility methods to do String Split by Comma
String[] | splitAtCommaOrPipe(String input) split At Comma Or Pipe ArrayList<String> result = new ArrayList<String>(); char character = '\0'; char previousCharacter; StringBuilder value = new StringBuilder(); for (int i = 0; i < input.length(); i++) { previousCharacter = character; character = input.charAt(i); if (character == ',' || character == '|') { ... |
List | splitComma(final String strWithComma) split Comma List<String> result = new ArrayList<>(); StringBuilder token = new StringBuilder(); int closureDepth = 0; boolean isStartMatch = false; for (int i = 0; i < strWithComma.length(); i++) { char c = strWithComma.charAt(i); switch (c) { case '$': ... |
List | splitComma(String configValue) split Comma if (configValue == null) { return null; String[] splits = configValue.split(","); List<String> list = new ArrayList<>(splits.length); for (String split : splits) { list.add(split.trim()); return list; |
String[] | splitCommand(String command) Split a command line into an argument array. char[] commandCharArr = command.toCharArray(); int idx = 0; int beginPos = 0; int endPos = 0; char ch = ' '; int state = 0; String argument = ""; ArrayList<String> argList = new ArrayList<String>(); ... |
List | splitCommand(String command) Split the commandline into separate elements by observing double quotes. List<String> list = new ArrayList<String>(); StringBuilder word = new StringBuilder(); boolean quote = false; int i = 0; while (i < command.length()) { char c = command.charAt(i); if (Character.isWhitespace(c) && !quote) { i++; ... |
String[] | splitCommand(String command) split Command List<String> elements = new ArrayList<String>(); String[] base = command.split(" "); int realIndex = 0; boolean inString = false; for (int i = 0; i < base.length; i++) { for (int j = 0; j < base[i].length(); j++) { if (base[i].charAt(j) == '"') { if (j == 0) ... |
ArrayList | splitCommandString(String command_string) split Command String command_string += " "; String[] substrings = command_string.split("\""); if (substrings.length % 2 == 0) { throw new RuntimeException("Unmatched parantheses in: " + command_string); ArrayList<String> output = new ArrayList<String>(); for (int i = 0; i < substrings.length; i++) { if ((i % 2) != 0) { ... |
ArrayList | splitCommaSequence(String argumentString) split Comma Sequence ArrayList<String> arguments = new ArrayList<String>(); int parCount = 0; int lastBeginIndex = 0; for (int i = 1; i < argumentString.length(); i++) { if (argumentString.charAt(i) == '(') parCount++; if (argumentString.charAt(i) == ')') parCount--; ... |
List | splitCommaStr(String commaStr) Given a comma-delimited string, split it into an array of strings, removing unneccessary whitespace. List<String> results = new ArrayList<String>(Arrays.asList(commaStr.trim().split("\\s*,\\s*"))); for (Iterator<String> it = results.iterator(); it.hasNext();) { String next = it.next(); next = next.trim(); if (next.equals("")) { it.remove(); return results; |
List | splitDoubleParentCommas(String input) split Double Parent Commas List<String> results = new ArrayList<String>(); if (input.charAt(0) != '(' || input.charAt(1) != '(' || input.charAt(input.length() - 2) != ')' || input.charAt(input.length() - 1) != ')') { throw new Exception("Invalid input"); String parts[] = input.substring(2, input.length() - 2).split("\\)\\)\\s*,\\s*\\(\\("); for (int i = 0; i < parts.length; i++) { if (parts[i].trim().length() > 0) { ... |