trimPatternRight method
trims Pattern on the end of the string
Implementation
String trimPatternRight(Pattern pattern) {
var res = this;
while (res.isNotEmpty && res._endsWithNonEmpty(pattern) != null) {
final newInput = res.replaceLast(pattern, '');
if (newInput.length >= res.length) {
assert(
false,
'trimming $res on the right incorrectly resulted in $newInput\n',
);
return res;
}
res = newInput;
}
return res;
}