File: preg_match_caseless_restrict.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (107 lines) | stat: -rw-r--r-- 3,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--TEST--
testing /r modifier in preg_* functions
--SKIPIF--
<?php
if (PCRE_VERSION_MAJOR == 10 && PCRE_VERSION_MINOR < 43) {
    die("skip old pcre version");
}
?>
--FILE--
<?php
echo "SK substitute matching" . PHP_EOL;
var_dump(preg_match('/AskZ/iur', 'AskZ')); // match
var_dump(preg_match('/AskZ/iur', 'aSKz')); // match
var_dump(preg_match('/AskZ/iur', "A\u{17f}kZ")); // no match
var_dump(preg_match('/AskZ/iur', "As\u{212a}Z")); // no match
var_dump(preg_match('/AskZ/iu', 'AskZ')); // match
var_dump(preg_match('/AskZ/iu', 'aSKz')); // match
var_dump(preg_match('/AskZ/iu', "A\u{17f}kZ")); // match
var_dump(preg_match('/AskZ/iu', "As\u{212a}Z")); // match

echo "K substitute matching" . PHP_EOL;
var_dump(preg_match('/k/iu', "\u{212A}"));
var_dump(preg_match('/k/iur', "\u{212A}"));

echo "non-ASCII in expressions" . PHP_EOL;
var_dump(preg_match('/A\x{17f}\x{212a}Z/iu', 'AskZ')); // match
var_dump(preg_match('/A\x{17f}\x{212a}Z/iur', 'AskZ')); // no match

echo "Character sets" . PHP_EOL;
var_dump(preg_match('/[AskZ]+/iur', 'AskZ')); // match
var_dump(preg_match('/[AskZ]+/iur', 'aSKz')); // match
var_dump(preg_match('/[AskZ]+/iur', "A\u{17f}kZ")); // match
var_dump(preg_match('/[AskZ]+/iur', "As\u{212a}Z")); // match
var_dump(preg_match('/[AskZ]+/iu', 'AskZ')); // match
var_dump(preg_match('/[AskZ]+/iu', 'aSKz')); // match
var_dump(preg_match('/[AskZ]+/iu', "A\u{17f}kZ")); // match
var_dump(preg_match('/[AskZ]+/iu', "As\u{212a}Z")); // match

echo "non-ASCII in character sets" . PHP_EOL;
var_dump(preg_match('/[\x{17f}\x{212a}]+/iur', 'AskZ')); // no match
var_dump(preg_match('/[\x{17f}\x{212a}]+/iu', 'AskZ')); // match

echo "Meta characters and negate character sets". PHP_EOL;
var_dump(preg_match('/[^s]+/iur', "A\u{17f}Z")); // match
var_dump(preg_match('/[^s]+/iu', "A\u{17f}Z")); // match
var_dump(preg_match('/[^s]+/iu', "A\u{17f}Z")); // match
var_dump(preg_match('/[^k]+/iur', "A\u{212a}Z")); // match
var_dump(preg_match('/[^k]+/iu', "A\u{212a}Z")); // match
var_dump(preg_match('/[^sk]+/iur', "A\u{17f}\u{212a}Z")); // match
var_dump(preg_match('/[^sk]+/iu', "A\u{17f}\u{212a}Z")); // match
var_dump(preg_match('/[^\x{17f}]+/iur', "AsSZ")); // match
var_dump(preg_match('/[^\x{17f}]+/iu', "AsSZ")); // match

echo "Modifier used within the expression" . PHP_EOL;
var_dump(preg_match('/s(?r)s(?-r)s(?r:s)s/iu', "\u{17f}S\u{17f}S\u{17f}")); // match
var_dump(preg_match('/s(?r)s(?-r)s(?r:s)s/iu', "\u{17f}\u{17f}\u{17f}S\u{17f}")); // no match
var_dump(preg_match('/s(?r)s(?-r)s(?r:s)s/iu', "\u{17f}S\u{17f}\u{17f}\u{17f}")); // no match
var_dump(preg_match('/k(?^i)k/iur', "K\u{212a}")); // match
var_dump(preg_match('/k(?^i)k/iur', "\u{212a}\u{212a}")); // no match

echo "Done";
?>
--EXPECT--
SK substitute matching
int(1)
int(1)
int(0)
int(0)
int(1)
int(1)
int(1)
int(1)
K substitute matching
int(1)
int(0)
non-ASCII in expressions
int(1)
int(0)
Character sets
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
non-ASCII in character sets
int(0)
int(1)
Meta characters and negate character sets
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
int(1)
Modifier used within the expression
int(1)
int(0)
int(0)
int(1)
int(0)
Done