xref: /PHP-8.2/ext/pcre/tests/bug70232.phpt (revision e03739d4)
1--TEST--
2Bug #70232 (Incorrect bump-along behavior with \K and empty string match)
3--FILE--
4<?php
5$pattern = '~(?: |\G)\d\B\K~';
6$subject = "123 a123 1234567 b123 123";
7preg_match_all($pattern, $subject, $matches);
8var_dump($matches);
9var_dump(preg_replace($pattern, "*", $subject));
10var_dump(preg_split($pattern, $subject));
11?>
12--EXPECT--
13array(1) {
14  [0]=>
15  array(10) {
16    [0]=>
17    string(0) ""
18    [1]=>
19    string(0) ""
20    [2]=>
21    string(0) ""
22    [3]=>
23    string(0) ""
24    [4]=>
25    string(0) ""
26    [5]=>
27    string(0) ""
28    [6]=>
29    string(0) ""
30    [7]=>
31    string(0) ""
32    [8]=>
33    string(0) ""
34    [9]=>
35    string(0) ""
36  }
37}
38string(35) "1*2*3 a123 1*2*3*4*5*6*7 b123 1*2*3"
39array(11) {
40  [0]=>
41  string(1) "1"
42  [1]=>
43  string(1) "2"
44  [2]=>
45  string(8) "3 a123 1"
46  [3]=>
47  string(1) "2"
48  [4]=>
49  string(1) "3"
50  [5]=>
51  string(1) "4"
52  [6]=>
53  string(1) "5"
54  [7]=>
55  string(1) "6"
56  [8]=>
57  string(8) "7 b123 1"
58  [9]=>
59  string(1) "2"
60  [10]=>
61  string(1) "3"
62}
63