splitAny method
Splits the string into multiple substrings using any of the specified delimiters.
The delimiters
parameter is a list of strings that represent the delimiters to use for splitting the string.
Returns a list of strings that are the result of splitting the original string using the specified delimiters.
Implementation
List<String> splitAny(Iterable<String> delimiters, [bool removeEmpty = false]) {
List<String> result = [this];
for (String delimiter in delimiters) {
List<String> temp = [];
for (String str in result) {
temp.addAll(str.split(delimiter));
}
result = temp;
}
if (removeEmpty) {
result = result.where((element) => element.isNotEmpty).toList();
}
return result;
}