RegEx groupCount varies between JavaScript vs Dart. #11674
Labels
area-vm
Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
closed-obsolete
Closed as the reported issue is no longer relevant
This issue was originally filed by demis.bell...@gmail.com
Dart only returns 4 groups whilst the same RegEx in JS returns 5 groups:
//Dart
var splitPathRe =
new RegExp(r"^(/?|)([\s\S]?)((?:.{1,2}|[^\/]+?|)(.[^.\/]|))(?:[/]*)$");
main(){
Match m = splitPathRe.firstMatch('/path.to/.file');
print(m.groupCount); //4
var groups = [];
for (var i=0; i<m.groupCount; i++)
groups.add(i);
print(m.groups(groups)); //[/path.to/.file, /, path.to/, .file]
}
/* JavaScript:
/^(/?|)([\s\S]?)((?:.{1,2}|[^\/]+?|)(.[^.\/]|))(?:[/]*)$/.exec('/path.to/.file')
//["/path.to/.file", "/", "path.to/", ".file", ""] //length = 5
*/
The text was updated successfully, but these errors were encountered: