xref: /PHP-8.3/ext/pcre/tests/match_flags2.phpt (revision a7bc2866)
1--TEST--
2preg_match() flags
3--FILE--
4<?php
5
6var_dump(preg_match('/x(.)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
7var_dump($match);
8
9var_dump(preg_match('/(.)x/', 'fjszxax', $match, PREG_OFFSET_CAPTURE, 4));
10var_dump($match);
11
12var_dump(preg_match('/(?P<capt1>.)(x)(?P<letsmix>\S+)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
13var_dump($match);
14
15?>
16--EXPECT--
17int(1)
18array(2) {
19  [0]=>
20  array(2) {
21    [0]=>
22    string(2) "xa"
23    [1]=>
24    int(4)
25  }
26  [1]=>
27  array(2) {
28    [0]=>
29    string(1) "a"
30    [1]=>
31    int(5)
32  }
33}
34int(1)
35array(2) {
36  [0]=>
37  array(2) {
38    [0]=>
39    string(2) "ax"
40    [1]=>
41    int(5)
42  }
43  [1]=>
44  array(2) {
45    [0]=>
46    string(1) "a"
47    [1]=>
48    int(5)
49  }
50}
51int(1)
52array(6) {
53  [0]=>
54  array(2) {
55    [0]=>
56    string(4) "zxax"
57    [1]=>
58    int(3)
59  }
60  ["capt1"]=>
61  array(2) {
62    [0]=>
63    string(1) "z"
64    [1]=>
65    int(3)
66  }
67  [1]=>
68  array(2) {
69    [0]=>
70    string(1) "z"
71    [1]=>
72    int(3)
73  }
74  [2]=>
75  array(2) {
76    [0]=>
77    string(1) "x"
78    [1]=>
79    int(4)
80  }
81  ["letsmix"]=>
82  array(2) {
83    [0]=>
84    string(2) "ax"
85    [1]=>
86    int(5)
87  }
88  [3]=>
89  array(2) {
90    [0]=>
91    string(2) "ax"
92    [1]=>
93    int(5)
94  }
95}
96