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

Unified Diff: sdk/lib/core/string.dart

Issue 17281002: Make String.startsWith take an optional start index. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review 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 | « sdk/lib/_internal/lib/js_string.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/string.dart
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index 0d2503a8e2c89dacaabd1d681dc69b4121432871..e2ffc235ef7b7f711a6c1a77efb5b41ae1977985 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -106,8 +106,18 @@ abstract class String implements Comparable<String>, Pattern {
/**
* Returns whether this string starts with a match of [pattern].
+ *
+ * If [index] is provided, instead check if the substring starting
+ * at that index starts with a match of [pattern].
+ *
+ * It is an error if [index] is negative or greater than [length].
+ *
+ * A [RegExp] containing "^" will not match if the [index] is greater than
+ * zero. The pattern works on the string as a whole, and does not extract
+ * a substring starting at [index] first. That is.
+ * "abc".startsWith(new RegExp("^.", 1)) == false
*/
- bool startsWith(Pattern pattern);
+ bool startsWith(Pattern pattern, [int index = 0]);
/**
* Returns the first position of a match of [pattern] in this string,
« no previous file with comments | « sdk/lib/_internal/lib/js_string.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698