| Index: runtime/lib/string_base.dart
|
| diff --git a/runtime/lib/string_base.dart b/runtime/lib/string_base.dart
|
| index 11b594ed9e562cebc71e654acdb8b433678031f5..81b01c9f70e138c93a398a65aba570bc033c533d 100644
|
| --- a/runtime/lib/string_base.dart
|
| +++ b/runtime/lib/string_base.dart
|
| @@ -210,12 +210,28 @@ class _StringBase {
|
| return buffer.add(this.substring(startIndex)).toString();
|
| }
|
|
|
| - String replaceAll(Pattern pattern, String replacement) {
|
| + String replaceAll(Pattern pattern, var replacement) {
|
| if (pattern is! Pattern) {
|
| throw new ArgumentError("${pattern} is not a Pattern");
|
| }
|
| + if (replacement is Function) {
|
| + StringBuffer buffer = new StringBuffer();
|
| + int startIndex = 0;
|
| + for (Match match in pattern.allMatches(this)) {
|
| + if (match.start > startIndex) {
|
| + buffer.add(this.substring(startIndex, match.start));
|
| + }
|
| + buffer.add(replacement(match).toString());
|
| + startIndex = match.end;
|
| + }
|
| + if (startIndex < this.length) {
|
| + buffer.add(this.substring(startIndex));
|
| + }
|
| + return buffer.toString();
|
| + }
|
| if (replacement is! String) {
|
| - throw new ArgumentError("${replacement} is not a String");
|
| + throw new ArgumentError(
|
| + "${replacement} is not a String or Match->String function");
|
| }
|
| StringBuffer buffer = new StringBuffer();
|
| int startIndex = 0;
|
|
|