split_basic_002.phpt 4.5 KB

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