Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: runtime/lib/regexp.dart

Issue 9718015: Make failed capturing parenthesis produce null instead of "". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: eliminate merge residue Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/regexp_jsc.cc » ('j') | runtime/lib/regexp_jsc.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | runtime/lib/regexp_jsc.cc » ('j') | runtime/lib/regexp_jsc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698