removeTrailing function

String removeTrailing(
  1. String pattern,
  2. String from
)

Implementation

String removeTrailing(String pattern, String from) {
  int i = from.length;
  while (from.startsWith(pattern, i - pattern.length)) {
    i -= pattern.length;
  }
  return from.substring(0, i);
}