Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2016 21:40
Show Gist options
  • Save anonymous/0bd2244aa9e93c300282d269f2eda0be to your computer and use it in GitHub Desktop.
Save anonymous/0bd2244aa9e93c300282d269f2eda0be to your computer and use it in GitHub Desktop.
Sample use case Regular Expression 
void main() {
///
/// sample using regexp to parse log
///
RegExp regExp = new RegExp(r"^(.*m)(\d{1,2}:\d{1,2}:\d{1,2},\d{1,3}) ([^\s]+) (.*)");
var input ="""
[0m[31m22:25:57,366 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."bad.war"
""";
var matches = regExp.allMatches(input);
Match match = matches.elementAt(0);
match.groupCount;
print(match[1]);
print(match[2]);
print(match[3]);
print(match[4]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment