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

Unified Diff: runtime/lib/regexp_patch.dart

Issue 15709018: Proof-of-concept matchPrefix on Pattern. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
Index: runtime/lib/regexp_patch.dart
diff --git a/runtime/lib/regexp_patch.dart b/runtime/lib/regexp_patch.dart
index fc7797f744b7312d6e5a010946d0dfbd10ad2624..2d457334f7190beac41137d7db0c730094fff388 100644
--- a/runtime/lib/regexp_patch.dart
+++ b/runtime/lib/regexp_patch.dart
@@ -81,6 +81,17 @@ class _JSSyntaxRegExp implements RegExp {
return new _AllMatchesIterable(this, str);
}
+ Match matchPrefix(String string, [int start = 0]) {
+ if (start < 0 || start > string.length) {
+ throw new RangeError.range(start, 0, string.length);
+ }
+ // Inefficient check that searches for a later match too.
+ List<int> list = _ExecuteMatch(string, start);
+ if (list == null) return null;
+ if (list[0] != start) return null;
+ return new _JSRegExpMatch(this, string, list);
+ }
+
bool hasMatch(String str) {
List match = _ExecuteMatch(str, 0);
return (match == null) ? false : true;

Powered by Google App Engine
This is Rietveld 408576698