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