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

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: Addressed other comments. 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
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/regexp_patch.dart
diff --git a/runtime/lib/regexp_patch.dart b/runtime/lib/regexp_patch.dart
index fc7797f744b7312d6e5a010946d0dfbd10ad2624..72b6f4bf827755d7465b50dab117aa45bef4a3cc 100644
--- a/runtime/lib/regexp_patch.dart
+++ b/runtime/lib/regexp_patch.dart
@@ -81,6 +81,18 @@ class _JSSyntaxRegExp implements RegExp {
return new _AllMatchesIterable(this, str);
}
+ Match matchAsPrefix(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.
+ // Change this when possible.
+ 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;
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698