beforeLast static method
Returns the portion of subject before the last occurrence of search.
Implementation
static String beforeLast(String subject, String search) {
if (search.isEmpty) return subject;
final index = subject.lastIndexOf(search);
if (index == -1) return subject;
return subject.substring(0, index);
}