getEverythingAfterLast method
Returns the substring after the last occurrence of find
.
Returns the original string if find
is not found.
Implementation
String getEverythingAfterLast(String find) {
if (find.isEmpty) {
return this;
}
// Find the last index of the target string.
final int atIndex = lastIndexOf(find);
// Return the substring after the last index, or the original string if not found.
return atIndex == -1 ? this : substring(atIndex + find.length);
}