matchAllJoin method

String matchAllJoin (
  1. RegExp regex,
  2. {String onNotFound = ''}
)

Extracting text from a string with regex groups

Implementation

String matchAllJoin(RegExp regex, {String onNotFound = ''}) {
  final matchedString = regex
      .allMatches(this)
      .map<String>((v) => v.group(0))
      .join(',')
      .replaceAll(',', '');

  return matchedString.isEmpty ? onNotFound : matchedString;
}