splitByLastOf function

List<String> splitByLastOf(
  1. String source,
  2. String pattern

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"


List<String> splitByLastOf(String source, String pattern) {
  var i = source.lastIndexOf(pattern);
  var r = [source.substring(0, i), source.substring(i + 1)];
  return r;