xref: /PHP-8.0/ext/pcre/tests/split.phpt (revision 852485d8)
1--TEST--
2preg_split()
3--FILE--
4<?php
5
6var_dump(preg_split('/*/', 'x'));
7
8var_dump(preg_split('/[\s, ]+/', 'x yy,zzz'));
9var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', -1));
10var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 0));
11var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 1));
12var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 2));
13
14var_dump(preg_split('/\d*/', 'ab2c3u'));
15var_dump(preg_split('/\d*/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY));
16
17?>
18--EXPECTF--
19Warning: preg_split(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %ssplit.php on line %d
20bool(false)
21array(3) {
22  [0]=>
23  string(1) "x"
24  [1]=>
25  string(2) "yy"
26  [2]=>
27  string(3) "zzz"
28}
29array(3) {
30  [0]=>
31  string(1) "x"
32  [1]=>
33  string(2) "yy"
34  [2]=>
35  string(3) "zzz"
36}
37array(3) {
38  [0]=>
39  string(1) "x"
40  [1]=>
41  string(2) "yy"
42  [2]=>
43  string(3) "zzz"
44}
45array(1) {
46  [0]=>
47  string(8) "x yy,zzz"
48}
49array(2) {
50  [0]=>
51  string(1) "x"
52  [1]=>
53  string(6) "yy,zzz"
54}
55array(8) {
56  [0]=>
57  string(0) ""
58  [1]=>
59  string(1) "a"
60  [2]=>
61  string(1) "b"
62  [3]=>
63  string(0) ""
64  [4]=>
65  string(1) "c"
66  [5]=>
67  string(0) ""
68  [6]=>
69  string(1) "u"
70  [7]=>
71  string(0) ""
72}
73array(4) {
74  [0]=>
75  string(1) "a"
76  [1]=>
77  string(1) "b"
78  [2]=>
79  string(1) "c"
80  [3]=>
81  string(1) "u"
82}
83