replaceAllWithCallback function
Replaces every match of pattern in input with the result of replace.
replace is called once per match and receives the Match, letting the
replacement depend on captured groups. Returns input unchanged when there
are no matches.
Example:
replaceAllWithCallback('a1b2', RegExp(r'\d'), (m) => '[${m[0]}]'); // 'a[1]b[2]'
Implementation
String replaceAllWithCallback(
String input,
RegExp pattern,
String Function(Match match) replace,
) => input.replaceAllMapped(pattern, replace);