1--TEST--
2Test preg_split() function : basic functionality
3--FILE--
4<?php
5/*
6* Function is implemented in ext/pcre/php_pcre.c
7*/
8$string = 'this is a_list: value1, Test__, string; Hello, world!_(parentheses)';
9var_dump(preg_split('/[:,;\(\)]/', $string, -1, PREG_SPLIT_NO_EMPTY)); //parts of $string separated by : , ; ( or ) are put into an array.
10var_dump(preg_split('/:\s*(\w*,*\s*)+;/', $string)); //all text between : and ; is removed
11var_dump(preg_split('/(\(|\))/', $string, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY)); //all text before (parentheses) is put into first element, ( into second, "parentheses" into third and ) into fourth.
12var_dump(preg_split('/NAME/i', $string)); //tries to find NAME regardless of case in $string (can't split it so just returns how string as first element)
13var_dump(preg_split('/\w/', $string, -1, PREG_SPLIT_NO_EMPTY)); //every character (including whitespace) is put into an array element
14
15?>
16--EXPECT--
17array(7) {
18  [0]=>
19  string(14) "this is a_list"
20  [1]=>
21  string(7) " value1"
22  [2]=>
23  string(7) " Test__"
24  [3]=>
25  string(7) " string"
26  [4]=>
27  string(6) " Hello"
28  [5]=>
29  string(8) " world!_"
30  [6]=>
31  string(11) "parentheses"
32}
33array(2) {
34  [0]=>
35  string(14) "this is a_list"
36  [1]=>
37  string(28) " Hello, world!_(parentheses)"
38}
39array(4) {
40  [0]=>
41  string(54) "this is a_list: value1, Test__, string; Hello, world!_"
42  [1]=>
43  string(1) "("
44  [2]=>
45  string(11) "parentheses"
46  [3]=>
47  string(1) ")"
48}
49array(1) {
50  [0]=>
51  string(67) "this is a_list: value1, Test__, string; Hello, world!_(parentheses)"
52}
53array(10) {
54  [0]=>
55  string(1) " "
56  [1]=>
57  string(1) " "
58  [2]=>
59  string(2) ": "
60  [3]=>
61  string(2) ", "
62  [4]=>
63  string(2) ", "
64  [5]=>
65  string(2) "; "
66  [6]=>
67  string(2) ", "
68  [7]=>
69  string(1) "!"
70  [8]=>
71  string(1) "("
72  [9]=>
73  string(1) ")"
74}
75