replaceAllAndFormat method

String replaceAllAndFormat(
  1. String text,
  2. RegExp pattern,
  3. String format
)

Implementation

String replaceAllAndFormat(String text, RegExp pattern, String format) {
  return text.replaceAllMapped(pattern, (match) {
    return format.replaceAllMapped(firstGroupPattern, (placeholderMatch) {
      final groupNumber = int.parse(placeholderMatch.group(1)!);
      return match.group(groupNumber) ?? '';
    });
  });
}