1--TEST--
2Test ereg_replace() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : proto string ereg_replace(string pattern, string replacement, string string)
6 * Description: Replace regular expression
7 * Source code: ext/standard/reg.c
8 * Alias to functions:
9 */
10
11/*
12 * Test a number of simple, valid matches with ereg_replace
13 */
14
15echo "*** Testing ereg() : basic functionality ***\n";
16
17include(dirname(__FILE__) . '/regular_expressions.inc');
18
19$replacement = '[this is a replacement]';
20
21foreach ($expressions as $re) {
22	list($pattern, $match) = $re;
23	echo "--> Pattern: '$pattern'; match: '$match'\n";
24	var_dump(ereg_replace($pattern, $replacement, $match . ' this contains some matches ' . $match));
25}
26
27echo "Done";
28?>
29--EXPECTF--
30*** Testing ereg() : basic functionality ***
31--> Pattern: '..(a|b|c)(a|b|c)..'; match: '--- ab ---'
32
33Deprecated: Function ereg_replace() is deprecated in %s on line %d
34string(82) "--[this is a replacement]-- this contains some matches --[this is a replacement]--"
35--> Pattern: '()'; match: ''
36
37Deprecated: Function ereg_replace() is deprecated in %s on line %d
38string(695) "[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]"
39--> Pattern: '()'; match: 'abcdef'
40
41Deprecated: Function ereg_replace() is deprecated in %s on line %d
42string(983) "[this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement] [this is a replacement]t[this is a replacement]h[this is a replacement]i[this is a replacement]s[this is a replacement] [this is a replacement]c[this is a replacement]o[this is a replacement]n[this is a replacement]t[this is a replacement]a[this is a replacement]i[this is a replacement]n[this is a replacement]s[this is a replacement] [this is a replacement]s[this is a replacement]o[this is a replacement]m[this is a replacement]e[this is a replacement] [this is a replacement]m[this is a replacement]a[this is a replacement]t[this is a replacement]c[this is a replacement]h[this is a replacement]e[this is a replacement]s[this is a replacement] [this is a replacement]a[this is a replacement]b[this is a replacement]c[this is a replacement]d[this is a replacement]e[this is a replacement]f[this is a replacement]"
43--> Pattern: '[x]|[^x]'; match: 'abcdef'
44
45Deprecated: Function ereg_replace() is deprecated in %s on line %d
46string(920) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement]"
47--> Pattern: '(a{1})(a{1,}) (b{1,3}) (c+) (d?ddd|e)'; match: '--- aaa bbb ccc ddd ---'
48
49Deprecated: Function ereg_replace() is deprecated in %s on line %d
50string(90) "--- [this is a replacement] --- this contains some matches --- [this is a replacement] ---"
51--> Pattern: '\\\`\^\.\[\$\(\)\|\*\+\?\{\''; match: '\`^.[$()|*+?{''
52
53Deprecated: Function ereg_replace() is deprecated in %s on line %d
54string(74) "[this is a replacement] this contains some matches [this is a replacement]"
55--> Pattern: '\a'; match: 'a'
56
57Deprecated: Function ereg_replace() is deprecated in %s on line %d
58string(118) "[this is a replacement] this cont[this is a replacement]ins some m[this is a replacement]tches [this is a replacement]"
59--> Pattern: '[0-9][^0-9]'; match: '2a'
60
61Deprecated: Function ereg_replace() is deprecated in %s on line %d
62string(74) "[this is a replacement] this contains some matches [this is a replacement]"
63--> Pattern: '^[[:alnum:]]{62,62}$'; match: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
64
65Deprecated: Function ereg_replace() is deprecated in %s on line %d
66string(152) "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ this contains some matches 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
67--> Pattern: '^[[:digit:]]{5}'; match: '0123456789'
68
69Deprecated: Function ereg_replace() is deprecated in %s on line %d
70string(66) "[this is a replacement]56789 this contains some matches 0123456789"
71--> Pattern: '[[:digit:]]{5}$'; match: '0123456789'
72
73Deprecated: Function ereg_replace() is deprecated in %s on line %d
74string(66) "0123456789 this contains some matches 01234[this is a replacement]"
75--> Pattern: '[[:blank:]]{1,10}'; match: '
76 	'
77
78Deprecated: Function ereg_replace() is deprecated in %s on line %d
79string(163) "
80[this is a replacement]this[this is a replacement]contains[this is a replacement]some[this is a replacement]matches[this is a replacement]
81[this is a replacement]"
82--> Pattern: '[[:print:]]{3}'; match: ' a '
83
84Deprecated: Function ereg_replace() is deprecated in %s on line %d
85string(254) "[this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement][this is a replacement] "
86Done
87