replaceRegionInText function
Implementation
String replaceRegionInText(List regions, String text) {
var replaced = text;
num offset = 0;
regions.forEach((region) {
var length = region['end'] - region['start'] + 1;
var replaceWith = '${getNumber(region)}';
replaced = splice(replaced, region['start'] + offset, length, replaceWith);
offset -= length - replaceWith.length;
});
return replaced;
}