Skip to content

Instantly share code, notes, and snippets.

@MahmoudMabrok
Created December 16, 2019 19:38
Show Gist options
  • Save MahmoudMabrok/c2c0ca775de8e0b34be63a476360c508 to your computer and use it in GitHub Desktop.
Save MahmoudMabrok/c2c0ca775de8e0b34be63a476360c508 to your computer and use it in GitHub Desktop.
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