blob: 7c152e7b46319a8b8ec8e8bd2bd5c392f8427cfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
--TEST--
mb_ereg_replace_callback()
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip mbstring not available');
function_exists('mb_ereg_replace_callback') or die("skip mb_ereg_replace_callback() is not available in this build");
?>
--FILE--
<?php
$str = 'abc 123 #",; $foo';
echo mb_ereg_replace_callback('(\S+)', function ($m) {
return $m[1].'('.strlen($m[1]).')';
}, $str), "\n";
echo mb_ereg_replace_callback('(?<word>\w+) (?<digit>\d+).*', function ($m) {
return sprintf("%s-%s", $m['digit'], $m['word']);
}, $str), "\n";
?>
--EXPECT--
abc(3) 123(3) #",;(4) $foo(4)
123-abc
|