Java Utililty Methods String Split by Regex

List of utility methods to do String Split by Regex

Description

The list of methods to do String Split by Regex are organized into topic(s).

Method

voidsplitString(String str, List list, String regex)
split String
int indexOf = str.indexOf(regex);
if (indexOf > -1) {
    list.add(str.substring(0, indexOf));
    splitString(str.substring(indexOf + 1, str.length()), list, regex);
} else {
    list.add(str);
ListsplitStringToList(String input, String regex)
splits a string on a regex delimeter and converts the resulting array to a List
if (input == null) {
    return Collections.emptyList();
List<String> results = new ArrayList<String>();
for (String value : input.split(regex)) {
    results.add(value.trim());
return results;
...
ListsplitTerms(String text, String pattern)
Splits the passed string around matches of the given pattern.
List<String> l = new ArrayList<String>();
if (text == null)
    return l;
text = text.trim();
String[] r = text.split(pattern);
String value;
for (int i = 0; i < r.length; i++) {
    value = r[i];
...
ListsplitToList(String s, String regex)
split To List
List<String> list = new ArrayList<String>();
for (String item : s.split(regex)) {
    if (!item.isEmpty()) {
        list.add(item);
return list;
ListsplitToLongList(String str, String regex)
split a string to a List with the given regular expression.
String[] strList = str.split(regex);
return convertStrArrayToLongList(strList);