xref: /PHP-5.5/ext/ereg/tests/eregi_basic_001.phpt (revision 1881091e)
1--TEST--
2Test eregi() function : basic functionality (with $regs)
3--FILE--
4<?php
5/* Prototype  : proto int eregi(string pattern, string string [, array registers])
6 * Description: Regular expression match
7 * Source code: ext/standard/reg.c
8 * Alias to functions:
9 */
10
11/*
12 * Test a number of simple, valid matches with eregi, specifying $regs
13 */
14
15echo "*** Testing eregi() : basic functionality ***\n";
16
17include(dirname(__FILE__) . '/regular_expressions.inc');
18
19foreach ($expressions as $re) {
20	list($pattern,$string) = $re;
21	echo "--> Pattern: '$pattern'; string: '$string'\n";
22	var_dump(eregi($pattern, $string, $regs));
23	var_dump($regs);
24}
25
26echo "Done";
27?>
28--EXPECTF--
29*** Testing eregi() : basic functionality ***
30--> Pattern: '..(a|b|c)(a|b|c)..'; string: '--- ab ---'
31
32Deprecated: Function eregi() is deprecated in %s on line %d
33int(6)
34array(3) {
35  [0]=>
36  string(6) "- ab -"
37  [1]=>
38  string(1) "a"
39  [2]=>
40  string(1) "b"
41}
42--> Pattern: '()'; string: ''
43
44Deprecated: Function eregi() is deprecated in %s on line %d
45int(1)
46array(2) {
47  [0]=>
48  bool(false)
49  [1]=>
50  bool(false)
51}
52--> Pattern: '()'; string: 'abcdef'
53
54Deprecated: Function eregi() is deprecated in %s on line %d
55int(1)
56array(2) {
57  [0]=>
58  bool(false)
59  [1]=>
60  bool(false)
61}
62--> Pattern: '[x]|[^x]'; string: 'abcdef'
63
64Deprecated: Function eregi() is deprecated in %s on line %d
65int(1)
66array(1) {
67  [0]=>
68  string(1) "a"
69}
70--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; string: '--- aaa bbb ccc ddd ---'
71
72Deprecated: Function eregi() is deprecated in %s on line %d
73int(15)
74array(6) {
75  [0]=>
76  string(15) "aaa bbb ccc ddd"
77  [1]=>
78  string(1) "a"
79  [2]=>
80  string(2) "aa"
81  [3]=>
82  string(3) "bbb"
83  [4]=>
84  string(3) "ccc"
85  [5]=>
86  string(3) "ddd"
87}
88--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; string: '\`^.[$()|*+?{''
89
90Deprecated: Function eregi() is deprecated in %s on line %d
91int(14)
92array(1) {
93  [0]=>
94  string(14) "\`^.[$()|*+?{'"
95}
96--> Pattern: '\a'; string: 'a'
97
98Deprecated: Function eregi() is deprecated in %s on line %d
99int(1)
100array(1) {
101  [0]=>
102  string(1) "a"
103}
104--> Pattern: '[0-9][^0-9]'; string: '2a'
105
106Deprecated: Function eregi() is deprecated in %s on line %d
107int(2)
108array(1) {
109  [0]=>
110  string(2) "2a"
111}
112--> Pattern: '^[[:alnum:]]{62,62}$'; string: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
113
114Deprecated: Function eregi() is deprecated in %s on line %d
115int(62)
116array(1) {
117  [0]=>
118  string(62) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
119}
120--> Pattern: '^[[:digit:]]{5}'; string: '0123456789'
121
122Deprecated: Function eregi() is deprecated in %s on line %d
123int(5)
124array(1) {
125  [0]=>
126  string(5) "01234"
127}
128--> Pattern: '[[:digit:]]{5}$'; string: '0123456789'
129
130Deprecated: Function eregi() is deprecated in %s on line %d
131int(5)
132array(1) {
133  [0]=>
134  string(5) "56789"
135}
136--> Pattern: '[[:blank:]]{1,10}'; string: '
137 	'
138
139Deprecated: Function eregi() is deprecated in %s on line %d
140int(2)
141array(1) {
142  [0]=>
143  string(2) " 	"
144}
145--> Pattern: '[[:print:]]{3}'; string: ' a '
146
147Deprecated: Function eregi() is deprecated in %s on line %d
148int(3)
149array(1) {
150  [0]=>
151  string(3) " a "
152}
153Done
154