| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class String { | 5 patch class String { |
| 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { | 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { |
| 7 return _StringBase.createFromCharCodes(charCodes); | 7 return _StringBase.createFromCharCodes(charCodes); |
| 8 } | 8 } |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 break; | 414 break; |
| 415 } else if (position == endIndex) { | 415 } else if (position == endIndex) { |
| 416 ++startIndex; // empty match, advance and restart | 416 ++startIndex; // empty match, advance and restart |
| 417 } else { | 417 } else { |
| 418 startIndex = endIndex; | 418 startIndex = endIndex; |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 return result; | 421 return result; |
| 422 } | 422 } |
| 423 | 423 |
| 424 Match matchAsPrefix(String string, [int start = 0]) { |
| 425 if (start < 0 || start > string.length) { |
| 426 throw new RangeError.range(start, 0, string.length); |
| 427 } |
| 428 if (start + this.length > string.length) return null; |
| 429 for (int i = 0; i < this.length; i++) { |
| 430 if (string.codeUnitAt(start + i) != this.codeUnitAt(i)) { |
| 431 return null; |
| 432 } |
| 433 } |
| 434 return new _StringMatch(start, string, this); |
| 435 } |
| 436 |
| 424 List<String> split(Pattern pattern) { | 437 List<String> split(Pattern pattern) { |
| 425 if ((pattern is String) && pattern.isEmpty) { | 438 if ((pattern is String) && pattern.isEmpty) { |
| 426 List<String> result = new List<String>(length); | 439 List<String> result = new List<String>(length); |
| 427 for (int i = 0; i < length; i++) { | 440 for (int i = 0; i < length; i++) { |
| 428 result[i] = this[i]; | 441 result[i] = this[i]; |
| 429 } | 442 } |
| 430 return result; | 443 return result; |
| 431 } | 444 } |
| 432 int length = this.length; | 445 int length = this.length; |
| 433 Iterator iterator = pattern.allMatches(this).iterator; | 446 Iterator iterator = pattern.allMatches(this).iterator; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 class _CodeUnits extends Object with ListMixin<int>, | 614 class _CodeUnits extends Object with ListMixin<int>, |
| 602 UnmodifiableListMixin<int> { | 615 UnmodifiableListMixin<int> { |
| 603 /** The string that this is the code units of. */ | 616 /** The string that this is the code units of. */ |
| 604 String _string; | 617 String _string; |
| 605 | 618 |
| 606 _CodeUnits(this._string); | 619 _CodeUnits(this._string); |
| 607 | 620 |
| 608 int get length => _string.length; | 621 int get length => _string.length; |
| 609 int operator[](int i) => _string.codeUnitAt(i); | 622 int operator[](int i) => _string.codeUnitAt(i); |
| 610 } | 623 } |
| OLD | NEW |