1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
--TEST--
Test spliti() function : basic functionality - test a number of simple spliti, specifying a limit
--FILE--
<?php
/* Prototype : proto array spliti(string pattern, string string [, int limit])
* Description: spliti string into array by regular expression
* Source code: ext/standard/reg.c
* Alias to functions:
*/
/*
* Test a number of simple spliti, specifying a limit
*/
echo "*** Testing ereg() : basic functionality ***\n";
include(dirname(__FILE__) . '/regular_expressions.inc');
foreach ($expressions as $re) {
list($pattern,$string) = $re;
echo "\n--> Pattern: '$pattern'; match: '$string'\n";
var_dump(spliti($pattern, $string . ' |1| ' . $string . ' |2| ' . $string, 2));
}
echo "Done";
?>
--EXPECTF--
*** Testing ereg() : basic functionality ***
--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(2) "--"
[1]=>
string(32) "-- |1| --- ab --- |2| --- ab ---"
}
--> Pattern: '()'; match: ''
Deprecated: Function spliti() is deprecated in %s on line %d
Warning: spliti(): Invalid Regular Expression in %s on line %d
bool(false)
--> Pattern: '()'; match: 'abcdef'
Deprecated: Function spliti() is deprecated in %s on line %d
Warning: spliti(): Invalid Regular Expression in %s on line %d
bool(false)
--> Pattern: '[x]|[^x]'; match: 'abcdef'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(27) "bcdef |1| abcdef |2| abcdef"
}
--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(4) "--- "
[1]=>
string(60) " --- |1| --- aaa bbb ccc ddd --- |2| --- aaa bbb ccc ddd ---"
}
--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(38) " |1| \`^.[$()|*+?{' |2| \`^.[$()|*+?{'"
}
--> Pattern: '\a'; match: 'a'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(12) " |1| a |2| a"
}
--> Pattern: '[0-9][^0-9]'; match: '2a'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(14) " |1| 2a |2| 2a"
}
--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
Deprecated: Function spliti() is deprecated in %s on line %d
array(1) {
[0]=>
string(196) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |1| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |2| 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
}
--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(35) "56789 |1| 0123456789 |2| 0123456789"
}
--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(35) "0123456789 |1| 0123456789 |2| 01234"
[1]=>
string(0) ""
}
--> Pattern: '[[:blank:]]{1,10}'; match: '
'
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(1) "
"
[1]=>
string(15) "|1|
|2|
"
}
--> Pattern: '[[:print:]]{3}'; match: ' a '
Deprecated: Function spliti() is deprecated in %s on line %d
array(2) {
[0]=>
string(0) ""
[1]=>
string(16) " |1| a |2| a "
}
Done
|