allBetween method
Searches the string for the first occurrence of startPattern
and the
last occurrence of endPattern
. It returns the string between that
occurrences.
Returns ''
if no occurrences were found.
Example:
'i like turtles'.allBetween('i ', ' turtles') // 'like'
Implementation
String allBetween(Pattern startPattern, Pattern endPattern) {
return allAfter(startPattern).allBefore(endPattern);
}