Skip to content

Instantly share code, notes, and snippets.

@MahmoudMabrok
Created Dec 16, 2019
Embed
What would you like to do?
void main() {
RegExp exp = new RegExp(r"[a-zA-Z]+");
String str = "Parse my string";
print('${getByToken(str, '[a-zA-Z]+')}');
}
List<String> getByToken(var str , var token){
RegExp exp = new RegExp("${token}");
print('${exp.pattern}');
Iterable<RegExpMatch> matches = exp.allMatches(str);
// print(matches.length);
var l = matches.map((t)=> t.group(0)).toList();
// print(l.length);
return l;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment