Index: runtime/lib/regexp.dart |
diff --git a/runtime/lib/regexp.dart b/runtime/lib/regexp.dart |
index e2f777e9ad5319301e855eb3cd85c489fba206be..6c0b741bb2340935b7818ff288311048ea117936 100644 |
--- a/runtime/lib/regexp.dart |
+++ b/runtime/lib/regexp.dart |
@@ -22,11 +22,17 @@ class JSRegExpMatch implements Match { |
} |
String group(int group) { |
- return str.substringUnchecked_(_start(group), _end(group)); |
+ if (group < 0 || group > regexp._groupCount) { |
+ throw new IndexOutOfRangeException(group); |
+ } |
+ if ((group * _kMatchPair) < _match.length ) { |
+ return str.substringUnchecked_(_start(group), _end(group)); |
+ } |
+ return null; |
} |
String operator [](int group) { |
- return str.substringUnchecked_(_start(group), _end(group)); |
+ return this.group(group); |
} |
List<String> groups(List<int> groups) { |