replaceMap method

String replaceMap(
  1. String source,
  2. Function map
)

String map(Match m) => replacement Depending on flag g uses replaceFirst or replaceAll

Implementation

String replaceMap(String source, Function map) {
  final Match match = _thisRE.firstMatch(source);
  if (match != null) {
    final String replacement = map(match);
    return global
        ? source.replaceAll(_thisRE, replacement)
        : source.replaceFirst(_thisRE, replacement);
  }
  return source;
}