OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 main() { | |
6 var list = "a b c".split(const RegExp(" ")); | |
7 Expect.equals(3, list.length); | |
8 Expect.equals("a", list[0]); | |
9 Expect.equals("b", list[1]); | |
10 Expect.equals("c", list[2]); | |
11 | |
12 list = "adbdc".split(const RegExp("[dz]")); | |
13 Expect.equals(3, list.length); | |
14 Expect.equals("a", list[0]); | |
15 Expect.equals("b", list[1]); | |
16 Expect.equals("c", list[2]); | |
17 | |
18 list = "addbddc".split(new RegExp("dd")); | |
19 Expect.equals(3, list.length); | |
20 Expect.equals("a", list[0]); | |
21 Expect.equals("b", list[1]); | |
22 Expect.equals("c", list[2]); | |
23 | |
24 list = "abc".split(new RegExp(@"b$")); | |
25 Expect.equals(1, list.length); | |
26 Expect.equals("abc", list[0]); | |
27 | |
28 list = "abc".split(new RegExp("")); | |
29 Expect.equals(3, list.length); | |
30 Expect.equals("a", list[0]); | |
31 Expect.equals("b", list[1]); | |
32 Expect.equals("c", list[2]); | |
33 | |
34 list = " ".split(new RegExp("[ ]")); | |
35 Expect.equals(4, list.length); | |
36 Expect.equals("", list[0]); | |
37 Expect.equals("", list[1]); | |
38 Expect.equals("", list[2]); | |
39 Expect.equals("", list[3]); | |
40 | |
41 list = "aaa".split(const RegExp(@"a$")); | |
42 Expect.equals(2, list.length); | |
43 Expect.equals("aa", list[0]); | |
44 Expect.equals("", list[1]); | |
45 } | |
OLD | NEW |