splitByLastOf function
Splits a string into two where it finds the pattern
closest to the right of the string
inp: "this is a test", " "
out: "this is a", "test"
Implementation
List<String> splitByLastOf(String source, String pattern) {
var i = source.lastIndexOf(pattern);
var r = [source.substring(0, i), source.substring(i + 1)];
return r;
}