List of utility methods to do String Split by Regex
Collection | split(final String regex, final String value) split return split(regex, value, new LinkedList<String>()); |
List | split(final String string, final String regex) split String tokens[] = string.split(regex);
return Arrays.asList(tokens);
|
String[] | split(String input, String regex) Splits the input string with the given regex and filters empty strings. if (input == null) { return null; String[] arr = input.split(regex); List<String> results = new ArrayList<>(arr.length); for (String a : arr) { if (!a.trim().isEmpty()) { results.add(a); ... |
List | split(String str, String regex) split List<String> strList = null; if (str == null || str.equals("")) { return strList; strList = Arrays.asList(str.split(regex)); return strList; |
List | split(String str, String regex) Splits the given string using the given regex as delimiters. return (Arrays.asList(str.split(regex)));
|
String[] | split(String string, String pattern) Split a string on pattern, making sure that we do not split on quoted sections. assert string != null; assert pattern != null; List<String> list = new ArrayList<String>(1); StringBuilder builder = new StringBuilder(); boolean inQuotes = false; for (int i = 0; i < string.length(); i++) { if (!inQuotes && match(pattern, string, i)) { list.add(builder.toString()); ... |
String[] | split(String text, String pattern) Splits a string given a pattern (regex), considering escapes. String[] array = text.split(pattern, -1); ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < array.length; i++) { boolean escaped = false; if (i > 0 && array[i - 1].endsWith("\\")) { int depth = 1; while (depth < array[i - 1].length() && array[i - 1].charAt(array[i - 1].length() - 1 - depth) == '\\') ... |
List | splitAndTrim(String s, String regex) split And Trim if (s == null) { return null; List<String> returnList = new ArrayList<>(); for (String string : s.split(regex)) { returnList.add(string.trim()); return returnList; ... |
List | splitList(String list, String splitRegex) split List String[] parts = list.split(splitRegex); List<String> finalParts = new ArrayList<String>(); for (String part : parts) { if (!part.equals("")) { finalParts.add(part); return finalParts; ... |
ArrayList | splitNoEmpty(String sStr, String regex) split No Empty String[] aIn = sStr.split(regex); ArrayList<String> lRes = new ArrayList<String>(); if (aIn.length == 0) { lRes.add(""); return lRes; for (int i = 0; i < aIn.length; i++) { if (!aIn[i].isEmpty() && !aIn[i].matches("\\s+") && aIn[i].length() > 1) { ... |