removeLastOccurrence method
Returns a new string with the last occurrence of target removed.
Implementation
@useResult
String removeLastOccurrence(String target) {
final int lastIndex = lastIndexOf(target);
if (lastIndex == -1) {
return this;
}
return substringSafe(0, lastIndex) + substringSafe(lastIndex + target.length);
}