betweenResultLast method
Returns a BetweenResult like betweenResult but searches from the end
using start and end delimiters.
When endOptional is true (default) and end is not found, returns
content after the last start. When trim is true (default), results
are trimmed.
Implementation
@useResult
BetweenResult? betweenResultLast(
String start,
String end, {
bool endOptional = true,
bool trim = true,
}) {
if (isEmpty) {
return null;
}
final String found = betweenLast(start, end, endOptional: endOptional, trim: trim);
if (found.isEmpty) {
return null;
}
final String removed = replaceFirst(start + found + end, '');
final String remaining = trim ? removed.replaceAll(RegExp(r'\s+'), ' ').trim() : removed;
return BetweenResult(found, remaining);
}