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