replaceLast static method
Replaces the last occurrence of search with replace in subject.
Implementation
static String replaceLast(String search, String replace, String subject) {
if (search.isEmpty) return subject;
final index = subject.lastIndexOf(search);
if (index == -1) return subject;
return subject.replaceFirst(search, replace, index);
}