Annotation of embedaddon/php/ext/pcre/tests/preg_match_all_basic.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test preg_match_all() function : basic functionality 
                      3: --FILE--
                      4: <?php
                      5: /*
1.1.1.2 ! misho       6: * proto int preg_match_all(string pattern, string subject, [array subpatterns [, int flags [, int offset]]])
1.1       misho       7: * Function is implemented in ext/pcre/php_pcre.c
                      8: */
                      9: $string = 'Hello, world! This is a test. This is another test. \[4]. 34534 string.';
                     10: var_dump(preg_match_all('/[0-35-9]/', $string, $match1, PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER, -10)); //finds any digit that's not 4 10 digits from the end(1 match)
                     11: var_dump($match1);
                     12: var_dump(preg_match_all('/[tT]his is a(.*?)\./', $string, $match2, PREG_SET_ORDER)); //finds "This is a test." and "This is another test." (non-greedy) (2 matches)
                     13: var_dump($match2);
                     14: var_dump(preg_match_all('@\. \\\(.*).@', $string, $match3, PREG_PATTERN_ORDER)); //finds ".\ [...]" and everything else to the end of the string. (greedy) (1 match)
                     15: var_dump($match3);
                     16: var_dump(preg_match_all('/\d{2}$/', $string, $match4)); //tries to find 2 digits at the end of a string (0 matches)
                     17: var_dump($match4);
                     18: var_dump(preg_match_all('/(This is a ){2}(.*)\stest/', $string, $match5)); //tries to find "This is aThis is a [...] test" (0 matches)
                     19: var_dump($match5);
1.1.1.2 ! misho      20: 
        !            21: // Test not passing in a subpatterns array.
        !            22: var_dump(preg_match_all('/test/', $string));
        !            23: var_dump(preg_match_all('/this isn\'t in the string/', $string));
        !            24: var_dump(preg_match_all('/world/', $string));
        !            25: var_dump(preg_match_all('/[0-9]/', $string));
1.1       misho      26: ?>
                     27: --EXPECTF--
                     28: int(1)
                     29: array(1) {
                     30:   [0]=>
                     31:   array(1) {
                     32:     [0]=>
                     33:     array(2) {
                     34:       [0]=>
                     35:       string(1) "3"
                     36:       [1]=>
                     37:       int(61)
                     38:     }
                     39:   }
                     40: }
                     41: int(2)
                     42: array(2) {
                     43:   [0]=>
                     44:   array(2) {
                     45:     [0]=>
                     46:     string(15) "This is a test."
                     47:     [1]=>
                     48:     string(5) " test"
                     49:   }
                     50:   [1]=>
                     51:   array(2) {
                     52:     [0]=>
                     53:     string(21) "This is another test."
                     54:     [1]=>
                     55:     string(11) "nother test"
                     56:   }
                     57: }
                     58: int(1)
                     59: array(2) {
                     60:   [0]=>
                     61:   array(1) {
                     62:     [0]=>
                     63:     string(21) ". \[4]. 34534 string."
                     64:   }
                     65:   [1]=>
                     66:   array(1) {
                     67:     [0]=>
                     68:     string(17) "[4]. 34534 string"
                     69:   }
                     70: }
                     71: int(0)
                     72: array(1) {
                     73:   [0]=>
                     74:   array(0) {
                     75:   }
                     76: }
                     77: int(0)
                     78: array(3) {
                     79:   [0]=>
                     80:   array(0) {
                     81:   }
                     82:   [1]=>
                     83:   array(0) {
                     84:   }
                     85:   [2]=>
                     86:   array(0) {
                     87:   }
                     88: }
1.1.1.2 ! misho      89: int(2)
        !            90: int(0)
        !            91: int(1)
        !            92: int(6)

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