| 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 List regExpExec(JSSyntaxRegExp regExp, String str) { | 5 List regExpExec(JSSyntaxRegExp regExp, String str) { |
| 6 var nativeRegExp = regExpGetNative(regExp); | 6 var nativeRegExp = regExpGetNative(regExp); |
| 7 var result = JS('List', r'#.exec(#)', nativeRegExp, str); | 7 var result = JS('List', r'#.exec(#)', nativeRegExp, str); |
| 8 if (JS('bool', r'# === null', result)) return null; | 8 if (JS('bool', r'# == null', result)) return null; |
| 9 return result; | 9 return result; |
| 10 } | 10 } |
| 11 | 11 |
| 12 bool regExpTest(JSSyntaxRegExp regExp, String str) { | 12 bool regExpTest(JSSyntaxRegExp regExp, String str) { |
| 13 var nativeRegExp = regExpGetNative(regExp); | 13 var nativeRegExp = regExpGetNative(regExp); |
| 14 return JS('bool', r'#.test(#)', nativeRegExp, str); | 14 return JS('bool', r'#.test(#)', nativeRegExp, str); |
| 15 } | 15 } |
| 16 | 16 |
| 17 regExpGetNative(JSSyntaxRegExp regExp) { | 17 regExpGetNative(JSSyntaxRegExp regExp) { |
| 18 var r = JS('var', r'#._re', regExp); | 18 var r = JS('var', r'#._re', regExp); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 if (global) sb.add('g'); | 37 if (global) sb.add('g'); |
| 38 try { | 38 try { |
| 39 return JS('Object', r'new RegExp(#, #)', pattern, sb.toString()); | 39 return JS('Object', r'new RegExp(#, #)', pattern, sb.toString()); |
| 40 } catch (e) { | 40 } catch (e) { |
| 41 throw new IllegalJSRegExpException(pattern, | 41 throw new IllegalJSRegExpException(pattern, |
| 42 JS('String', r'String(#)', e)); | 42 JS('String', r'String(#)', e)); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 int regExpMatchStart(m) => JS('int', r'#.index', m); | 46 int regExpMatchStart(m) => JS('int', r'#.index', m); |
| OLD | NEW |