grep function

List grep(
  1. dynamic sexp,
  2. dynamic text, [
  3. dynamic groupId = 0
])

Implementation

List grep(sexp, text, [groupId=0]) {
    var list = [];
    RegExp exp = RegExp(sexp);
    Iterable<RegExpMatch> matches = exp.allMatches(text);
    for (var m in matches) {
        if (m != null) list.add(m.group(groupId));
    }
    return list;
}