Regex using Dart lang
When running Dart in a browser, it uses the browser's regex engine, and if it supports named capturing groups they will be supported. If not, they won't. When running your code in Flutter, or standalone Dart, namedGroup
works as you'd expect.
Use numbered capturing groups and access them by their indices:
RegExp regExp = new RegExp(r"^(.*m)(\d{1,2}:\d{1,2}:\d{1,2},\d{1,3}) ([^\s]+) (.*)");
See this regex demo
In Dart, try something like this:
RegExp regExp = new RegExp(r"^(.*m)(\d{1,2}:\d{1,2}:\d{1,2},\d{1,3}) ([^\s]+) (.*)");String s = "[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\"";Iterable<Match> matches = regExp.allMatches(s);for (Match match in matches) { print("${match.group(1)}\n"); print("${match.group(2)}\n"); print("${match.group(3)}\n"); print("${match.group(4)}\n");}
See this DartPad demo
For future readers, as Scott Hyndman explains in a comment, this is now supported with RegExpMatch.https://api.dartlang.org/stable/2.4.0/dart-core/RegExp-class.html
This does appear to be working in DartPad now (with dart 2.4.0 at least).https://dartpad.dartlang.org/de5fafc572ebb786c9b4791229c65a9b