getEverythingBefore method
Returns the substringSafe before the first occurrence of find.
Returns the original string if find is not found.
Implementation
String getEverythingBefore(String find) {
// Find the index of the target string.
final int atIndex = indexOf(find);
// Return the substringSafe before the index, or the original string if not found.
return atIndex == -1 ? this : substringSafe(0, atIndex);
}