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

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

Issue 11312144: Allow function as replacement argument to String.replaceAll. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Created 8 years, 1 month 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/core/regexp.dart ('k') | tests/corelib/corelib.status » ('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 ad4aefee7e1fca8b4e591dd6fed3f8de54c22e9d..d9c0587e8f47ba822b9f010940fb8d5973fbd2d6 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -99,9 +99,14 @@ interface String
/**
* Returns a new string where all occurences of [from] in this string
- * are replaced with [to].
- */
- String replaceAll(Pattern from, String to);
+ * are replaced with a [String] depending on [replace].
+ *
+ * If [replace] is a [Function], it's called with the [Match] generated
+ * by the pattern, and its result is used as replacement.
+ * Otherwise, [replace] must be a [String], which is directly used as
+ * the replacement.
+ */
+ String replaceAll(Pattern from, var replace);
/**
* Splits the string around matches of [pattern]. Returns
« no previous file with comments | « sdk/lib/core/regexp.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698