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