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 class StringMatch implements Match { | 5 class StringMatch implements Match { |
6 const StringMatch(int this._start, | 6 const StringMatch(int this._start, |
7 String this.str, | 7 String this.str, |
8 String this.pattern); | 8 String this.pattern); |
9 | 9 |
10 int start() => _start; | 10 int start() => _start; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return result; | 57 return result; |
58 } | 58 } |
59 | 59 |
60 stringContainsUnchecked(receiver, other, startIndex) { | 60 stringContainsUnchecked(receiver, other, startIndex) { |
61 if (other is String) { | 61 if (other is String) { |
62 return receiver.indexOf(other, startIndex) != -1; | 62 return receiver.indexOf(other, startIndex) != -1; |
63 } else if (other is JSSyntaxRegExp) { | 63 } else if (other is JSSyntaxRegExp) { |
64 return other.hasMatch(receiver.substring(startIndex)); | 64 return other.hasMatch(receiver.substring(startIndex)); |
65 } else { | 65 } else { |
66 var substr = receiver.substring(startIndex); | 66 var substr = receiver.substring(startIndex); |
67 return other.allMatches(substr).iterator().hasNext(); | 67 return other.allMatches(substr).iterator().hasNext; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 stringReplaceJS(receiver, replacer, to) { | 71 stringReplaceJS(receiver, replacer, to) { |
72 // The JavaScript String.replace method recognizes replacement | 72 // The JavaScript String.replace method recognizes replacement |
73 // patterns in the replacement string. Dart does not have that | 73 // patterns in the replacement string. Dart does not have that |
74 // behavior. | 74 // behavior. |
75 to = JS('String', r"#.replace('$', '$$$$')", to); | 75 to = JS('String', r"#.replace('$', '$$$$')", to); |
76 return JS('String', r'#.replace(#, #)', receiver, replacer, to); | 76 return JS('String', r'#.replace(#, #)', receiver, replacer, to); |
77 } | 77 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 var re = regExpGetNative(pattern); | 130 var re = regExpGetNative(pattern); |
131 return JS('List', r'#.split(#)', receiver, re); | 131 return JS('List', r'#.split(#)', receiver, re); |
132 } else { | 132 } else { |
133 throw "StringImplementation.split(Pattern) UNIMPLEMENTED"; | 133 throw "StringImplementation.split(Pattern) UNIMPLEMENTED"; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 stringJoinUnchecked(array, separator) { | 137 stringJoinUnchecked(array, separator) { |
138 return JS('String', r'#.join(#)', array, separator); | 138 return JS('String', r'#.join(#)', array, separator); |
139 } | 139 } |
OLD | NEW |