| 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 RegExp { | 5 patch class RegExp { |
| 6 /* patch */ factory RegExp(String pattern, | 6 /* patch */ factory RegExp(String pattern, |
| 7 {bool multiLine: false, | 7 {bool multiLine: false, |
| 8 bool caseSensitive: true}) { | 8 bool caseSensitive: true}) { |
| 9 return new _JSSyntaxRegExp(pattern, | 9 return new _JSSyntaxRegExp(pattern, |
| 10 multiLine: multiLine, | 10 multiLine: multiLine, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return null; | 74 return null; |
| 75 } | 75 } |
| 76 return new _JSRegExpMatch(this, str, match); | 76 return new _JSRegExpMatch(this, str, match); |
| 77 } | 77 } |
| 78 | 78 |
| 79 Iterable<Match> allMatches(String str) { | 79 Iterable<Match> allMatches(String str) { |
| 80 if (str is! String) throw new ArgumentError(str); | 80 if (str is! String) throw new ArgumentError(str); |
| 81 return new _AllMatchesIterable(this, str); | 81 return new _AllMatchesIterable(this, str); |
| 82 } | 82 } |
| 83 | 83 |
| 84 Match matchAsPrefix(String string, [int start = 0]) { |
| 85 if (start < 0 || start > string.length) { |
| 86 throw new RangeError.range(start, 0, string.length); |
| 87 } |
| 88 // Inefficient check that searches for a later match too. |
| 89 // Change this when possible. |
| 90 List<int> list = _ExecuteMatch(string, start); |
| 91 if (list == null) return null; |
| 92 if (list[0] != start) return null; |
| 93 return new _JSRegExpMatch(this, string, list); |
| 94 } |
| 95 |
| 84 bool hasMatch(String str) { | 96 bool hasMatch(String str) { |
| 85 List match = _ExecuteMatch(str, 0); | 97 List match = _ExecuteMatch(str, 0); |
| 86 return (match == null) ? false : true; | 98 return (match == null) ? false : true; |
| 87 } | 99 } |
| 88 | 100 |
| 89 String stringMatch(String str) { | 101 String stringMatch(String str) { |
| 90 List match = _ExecuteMatch(str, 0); | 102 List match = _ExecuteMatch(str, 0); |
| 91 if (match == null) { | 103 if (match == null) { |
| 92 return null; | 104 return null; |
| 93 } | 105 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 var match = _re._ExecuteMatch(_str, nextIndex); | 154 var match = _re._ExecuteMatch(_str, nextIndex); |
| 143 if (match == null) { | 155 if (match == null) { |
| 144 _current = null; | 156 _current = null; |
| 145 _re = null; | 157 _re = null; |
| 146 return false; | 158 return false; |
| 147 } | 159 } |
| 148 _current = new _JSRegExpMatch(_re, _str, match); | 160 _current = new _JSRegExpMatch(_re, _str, match); |
| 149 return true; | 161 return true; |
| 150 } | 162 } |
| 151 } | 163 } |
| OLD | NEW |