Annotation of embedaddon/php/ext/pcre/tests/preg_split_basic.phpt, revision 1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>