betweenResultLast method

(String, String?)? betweenResultLast(
  1. String start,
  2. String end, {
  3. bool endOptional = true,
  4. bool trim = true,
})

Same as betweenResult but searches from the end.

Implementation

(String, String?)? 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 (found, remaining);
}