xref: /PHP-5.4/ext/ereg/tests/split_basic_002.phpt (revision 1881091e)
1--TEST--
2Test split() function : basic functionality - test a number of simple split, without specifying a limit
3--FILE--
4<?php
5/* Prototype  : proto array split(string pattern, string string [, int limit])
6 * Description: Split string into array by regular expression
7 * Source code: ext/standard/reg.c
8 * Alias to functions:
9 */
10
11/*
12 * Test a number of simple split, without specifying a limit
13 */
14
15echo "*** Testing ereg() : basic functionality ***\n";
16
17include(dirname(__FILE__) . '/regular_expressions.inc');
18
19foreach ($expressions as $re) {
20	list($pattern,$string) = $re;
21	echo "\n--> Pattern: '$pattern'; match: '$string'\n";
22	var_dump(split($pattern, $string . ' |1| ' . $string . ' |2| ' . $string));
23}
24
25echo "Done";
26?>
27--EXPECTF--
28*** Testing ereg() : basic functionality ***
29
30--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
31
32Deprecated: Function split() is deprecated in %s on line %d
33array(4) {
34  [0]=>
35  string(2) "--"
36  [1]=>
37  string(9) "-- |1| --"
38  [2]=>
39  string(9) "-- |2| --"
40  [3]=>
41  string(2) "--"
42}
43
44--> Pattern: '()'; match: ''
45
46Deprecated: Function split() is deprecated in %s on line %d
47
48Warning: split(): Invalid Regular Expression in %s on line %d
49bool(false)
50
51--> Pattern: '()'; match: 'abcdef'
52
53Deprecated: Function split() is deprecated in %s on line %d
54
55Warning: split(): Invalid Regular Expression in %s on line %d
56bool(false)
57
58--> Pattern: '[x]|[^x]'; match: 'abcdef'
59
60Deprecated: Function split() is deprecated in %s on line %d
61array(29) {
62  [0]=>
63  string(0) ""
64  [1]=>
65  string(0) ""
66  [2]=>
67  string(0) ""
68  [3]=>
69  string(0) ""
70  [4]=>
71  string(0) ""
72  [5]=>
73  string(0) ""
74  [6]=>
75  string(0) ""
76  [7]=>
77  string(0) ""
78  [8]=>
79  string(0) ""
80  [9]=>
81  string(0) ""
82  [10]=>
83  string(0) ""
84  [11]=>
85  string(0) ""
86  [12]=>
87  string(0) ""
88  [13]=>
89  string(0) ""
90  [14]=>
91  string(0) ""
92  [15]=>
93  string(0) ""
94  [16]=>
95  string(0) ""
96  [17]=>
97  string(0) ""
98  [18]=>
99  string(0) ""
100  [19]=>
101  string(0) ""
102  [20]=>
103  string(0) ""
104  [21]=>
105  string(0) ""
106  [22]=>
107  string(0) ""
108  [23]=>
109  string(0) ""
110  [24]=>
111  string(0) ""
112  [25]=>
113  string(0) ""
114  [26]=>
115  string(0) ""
116  [27]=>
117  string(0) ""
118  [28]=>
119  string(0) ""
120}
121
122--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
123
124Deprecated: Function split() is deprecated in %s on line %d
125array(4) {
126  [0]=>
127  string(4) "--- "
128  [1]=>
129  string(13) " --- |1| --- "
130  [2]=>
131  string(13) " --- |2| --- "
132  [3]=>
133  string(4) " ---"
134}
135
136--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
137
138Deprecated: Function split() is deprecated in %s on line %d
139array(4) {
140  [0]=>
141  string(0) ""
142  [1]=>
143  string(5) " |1| "
144  [2]=>
145  string(5) " |2| "
146  [3]=>
147  string(0) ""
148}
149
150--> Pattern: '\a'; match: 'a'
151
152Deprecated: Function split() is deprecated in %s on line %d
153array(4) {
154  [0]=>
155  string(0) ""
156  [1]=>
157  string(5) " |1| "
158  [2]=>
159  string(5) " |2| "
160  [3]=>
161  string(0) ""
162}
163
164--> Pattern: '[0-9][^0-9]'; match: '2a'
165
166Deprecated: Function split() is deprecated in %s on line %d
167array(6) {
168  [0]=>
169  string(0) ""
170  [1]=>
171  string(2) " |"
172  [2]=>
173  string(1) " "
174  [3]=>
175  string(2) " |"
176  [4]=>
177  string(1) " "
178  [5]=>
179  string(0) ""
180}
181
182--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
183
184Deprecated: Function split() is deprecated in %s on line %d
185array(1) {
186  [0]=>
187  string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
188}
189
190--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
191
192Deprecated: Function split() is deprecated in %s on line %d
193array(3) {
194  [0]=>
195  string(0) ""
196  [1]=>
197  string(0) ""
198  [2]=>
199  string(30) " |1| 0123456789 |2| 0123456789"
200}
201
202--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
203
204Deprecated: Function split() is deprecated in %s on line %d
205array(2) {
206  [0]=>
207  string(35) "0123456789 |1| 0123456789 |2| 01234"
208  [1]=>
209  string(0) ""
210}
211
212--> Pattern: '[[:blank:]]{1,10}'; match: '
213 	'
214
215Deprecated: Function split() is deprecated in %s on line %d
216array(6) {
217  [0]=>
218  string(1) "
219"
220  [1]=>
221  string(3) "|1|"
222  [2]=>
223  string(1) "
224"
225  [3]=>
226  string(3) "|2|"
227  [4]=>
228  string(1) "
229"
230  [5]=>
231  string(0) ""
232}
233
234--> Pattern: '[[:print:]]{3}'; match: ' a '
235
236Deprecated: Function split() is deprecated in %s on line %d
237array(7) {
238  [0]=>
239  string(0) ""
240  [1]=>
241  string(0) ""
242  [2]=>
243  string(0) ""
244  [3]=>
245  string(0) ""
246  [4]=>
247  string(0) ""
248  [5]=>
249  string(0) ""
250  [6]=>
251  string(1) " "
252}
253Done
254