xref: /PHP-7.3/ext/pcre/tests/bug61780_1.phpt (revision 3c43510b)
1--TEST--
2Bug #61780 (Inconsistent PCRE captures in match results): numeric subpatterns
3--FILE--
4<?php
5preg_match('/(4)?(2)?\d/', '23456', $matches, PREG_UNMATCHED_AS_NULL);
6var_export($matches);
7echo "\n\n";
8preg_match('/(4)?(2)?\d/', '23456', $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);
9var_export($matches);
10echo "\n\n";
11preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_UNMATCHED_AS_NULL);
12var_export($matches);
13echo "\n\n";
14preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);
15var_export($matches);
16echo "\n\n";
17preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL);
18var_export($matches);
19echo "\n\n";
20preg_match_all('/(4)?(2)?\d/', '123456', $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);
21var_export($matches);
22?>
23--EXPECT--
24array (
25  0 => '23',
26  1 => NULL,
27  2 => '2',
28)
29
30array (
31  0 =>
32  array (
33    0 => '23',
34    1 => 0,
35  ),
36  1 =>
37  array (
38    0 => NULL,
39    1 => -1,
40  ),
41  2 =>
42  array (
43    0 => '2',
44    1 => 0,
45  ),
46)
47
48array (
49  0 =>
50  array (
51    0 => '1',
52    1 => '23',
53    2 => '45',
54    3 => '6',
55  ),
56  1 =>
57  array (
58    0 => NULL,
59    1 => NULL,
60    2 => '4',
61    3 => NULL,
62  ),
63  2 =>
64  array (
65    0 => NULL,
66    1 => '2',
67    2 => NULL,
68    3 => NULL,
69  ),
70)
71
72array (
73  0 =>
74  array (
75    0 =>
76    array (
77      0 => '1',
78      1 => 0,
79    ),
80    1 =>
81    array (
82      0 => '23',
83      1 => 1,
84    ),
85    2 =>
86    array (
87      0 => '45',
88      1 => 3,
89    ),
90    3 =>
91    array (
92      0 => '6',
93      1 => 5,
94    ),
95  ),
96  1 =>
97  array (
98    0 => NULL,
99    1 =>
100    array (
101      0 => NULL,
102      1 => -1,
103    ),
104    2 =>
105    array (
106      0 => '4',
107      1 => 3,
108    ),
109    3 => NULL,
110  ),
111  2 =>
112  array (
113    0 => NULL,
114    1 =>
115    array (
116      0 => '2',
117      1 => 1,
118    ),
119    2 => NULL,
120    3 => NULL,
121  ),
122)
123
124array (
125  0 =>
126  array (
127    0 => '1',
128  ),
129  1 =>
130  array (
131    0 => '23',
132    1 => NULL,
133    2 => '2',
134  ),
135  2 =>
136  array (
137    0 => '45',
138    1 => '4',
139  ),
140  3 =>
141  array (
142    0 => '6',
143  ),
144)
145
146array (
147  0 =>
148  array (
149    0 =>
150    array (
151      0 => '1',
152      1 => 0,
153    ),
154  ),
155  1 =>
156  array (
157    0 =>
158    array (
159      0 => '23',
160      1 => 1,
161    ),
162    1 =>
163    array (
164      0 => NULL,
165      1 => -1,
166    ),
167    2 =>
168    array (
169      0 => '2',
170      1 => 1,
171    ),
172  ),
173  2 =>
174  array (
175    0 =>
176    array (
177      0 => '45',
178      1 => 3,
179    ),
180    1 =>
181    array (
182      0 => '4',
183      1 => 3,
184    ),
185  ),
186  3 =>
187  array (
188    0 =>
189    array (
190      0 => '6',
191      1 => 5,
192    ),
193  ),
194)
195