[Dart] splitMapJoin

  var str3 = '''Multi
  Line
  String''';

  print( str3.splitMapJoin(
      RegExp(r'^', multiLine: true), // Matches the beginning of the line
      onMatch: (m) => '** ${m.group(0)}', // Adds asterisk to match
      onNonMatch: (n) => n // Just return non-matches
  ) ); 

/* ** Multi ** Line ** String*/

 

posted @ 2019-09-04 15:18  Zhentiw  阅读(902)  评论(0编辑  收藏  举报