| Index: sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
|
| index 45ab03c85aa57d738c66c9740c750559c7926247..d2feaa81ee5643a83bdcfab971d401199ca6684d 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
|
| @@ -33,6 +33,12 @@ class JSSyntaxRegExp implements RegExp {
|
| other.isCaseSensitive,
|
| true);
|
|
|
| + JSSyntaxRegExp._anchoredVersionOf(JSSyntaxRegExp other)
|
| + : this._internal(other.pattern + "|()",
|
| + other.isMultiLine,
|
| + other.isCaseSensitive,
|
| + true);
|
| +
|
| static makeNative(
|
| String pattern, bool multiLine, bool caseSensitive, bool global) {
|
| checkString(pattern);
|
| @@ -82,6 +88,26 @@ 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);
|
| + }
|
| + // An "anchored version" of a regexp is created by adding "|()" to the
|
| + // source. This means that the regexp always matches at the first position
|
| + // that it tries, and you can see if the original regexp matched, or it
|
| + // was the added zero-width match that matched, by looking at the last
|
| + // capture. If it is a String, the match participated, otherwise it didn't.
|
| + JSSyntaxRegExp regexp = new JSSyntaxRegExp._anchoredVersionOf(this);
|
| + if (start > 0) {
|
| + JS("void", "#.lastIndex = #", regExpGetNative(regexp), start);
|
| + }
|
| + _MatchImplementation match = regexp.firstMatch(string);
|
| + if (match == null) return null;
|
| + if (match._groups[match._groups.length - 1] != null) return null;
|
| + match._groups.length -= 1;
|
| + return match;
|
| + }
|
| +
|
| String get pattern => _pattern;
|
| bool get isMultiLine => _isMultiLine;
|
| bool get isCaseSensitive => _isCaseSensitive;
|
|
|