retrieve method
Retrieve values from an interpolated string input
Use with care since values may contain the same patterns that divide values
Implementation
Map<String, String> retrieve(String input){
int index = 0;
int start = 0;
Map<String, String> ret = {};
for(final key in _subs){
final prefix = _bodySegs[index];
start += prefix.length;
final val = RegExp("(?<=${prefix}).*?(?=${_bodySegs[++index]})")
.matchAsPrefix(input, start)?.group(0);
ret[key] = val ?? (throw FormatException("Corrupted input String"));
start += val.length;
}
//Escape characters are not keys
return ret..remove("pre")..remove("suf");
}