replacingOccurrences method
Replaces occurrences of the matching pattern in the string with the provided replacement function. Uses a regular expression to find matches and applies the replacement function to each match.
Implementation
String replacingOccurrences({
required String matchingPattern,
required String Function(String) replacementProvider,
}) {
final regExp = RegExp(matchingPattern);
return replaceAllMapped(
regExp,
(match) => replacementProvider(match.group(0)!),
);
}