replaceData function

String replaceData(
  1. String input,
  2. Map<Pattern, dynamic> data
)

Replaces the keys of data in input with the corresponding values.

Implementation

String replaceData(String input, Map<Pattern, dynamic> data) {
  var output = input;
  for (final entry in data.entries) {
    final pattern = entry.key;
    final value = entry.value;
    output = output.replaceAll(pattern, value.toString());
  }
  return output;
}