Annotation of embedaddon/php/ext/pcre/tests/preg_match_basic_edit.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test preg_match() function : basic functionality 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
                      6:  * Description: Perform a Perl-style regular expression match 
                      7:  * Source code: ext/pcre/php_pcre.c
                      8:  * Alias to functions: 
                      9: */
                     10: 
                     11: 
                     12: $string = 'Hello, world. [*], this is \ a string';
                     13: 
                     14: var_dump(preg_match('/^[hH]ello,\s/', $string, $match1));                                                      //finds "Hello, "
                     15: var_dump($match1);
                     16: 
                     17: var_dump(preg_match('/l^o,\s\w{5}/', $string, $match2, PREG_OFFSET_CAPTURE));                          // tries to find "lo, world" at start of string
                     18: var_dump($match2);
                     19: 
                     20: var_dump(preg_match('/\[\*\],\s(.*)/', $string, $match3));                                                     //finds "[*], this is \ a string";
                     21: var_dump($match3);
                     22: 
                     23: var_dump(preg_match('@\w{4}\s\w{2}\s\\\(?:\s.*)@', $string, $match4, PREG_OFFSET_CAPTURE, 14));        //finds "this is \ a string" (with non-capturing parentheses)
                     24: var_dump($match4);
                     25: 
                     26: var_dump(preg_match('/hello world/', $string, $match5));                                                       //tries to find "hello world" (should be Hello, world)
                     27: var_dump($match5);
                     28: ?>
                     29: 
                     30: --EXPECTF--
                     31: 
                     32: int(1)
                     33: array(1) {
                     34:   [0]=>
                     35:   string(7) "Hello, "
                     36: }
                     37: int(0)
                     38: array(0) {
                     39: }
                     40: int(1)
                     41: array(2) {
                     42:   [0]=>
                     43:   string(23) "[*], this is \ a string"
                     44:   [1]=>
                     45:   string(18) "this is \ a string"
                     46: }
                     47: int(1)
                     48: array(1) {
                     49:   [0]=>
                     50:   array(2) {
                     51:     [0]=>
                     52:     string(18) "this is \ a string"
                     53:     [1]=>
                     54:     int(19)
                     55:   }
                     56: }
                     57: int(0)
                     58: array(0) {
                     59: }
                     60: 

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