Skip to content

Instantly share code, notes, and snippets.

@krooq
Created June 30, 2019 04:57
Show Gist options
  • Save krooq/de5fafc572ebb786c9b4791229c65a9b to your computer and use it in GitHub Desktop.
Save krooq/de5fafc572ebb786c9b4791229c65a9b to your computer and use it in GitHub Desktop.
void main() {
final RegExp pattern = RegExp(r"(?<quantity>\d+) (?<unit>\w+)");
final RegExpMatch matches = pattern.firstMatch("2 weeks");
print(matches.namedGroup("quantity"));
print(matches.namedGroup("unit"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment