1--TEST-- 2Test mb_ereg_replace() function : basic 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_ereg_replace') or die("skip mb_ereg_replace() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* 11 * Test Basic Functionality of mb_ereg_replace() 12 */ 13 14echo "*** Testing mb_ereg_replace() : basic functionality ***\n"; 15 16mb_internal_encoding('UTF-8'); 17mb_regex_encoding('UTF-8'); 18 19$string_ascii = 'abc def'; 20$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); 21 22echo "\n-- ASCII string 1 --\n"; 23$result_1 = mb_ereg_replace('(.*)def', '\\1 123', $string_ascii); 24var_dump(bin2hex($result_1)); 25 26echo "\n-- ASCII string 2 --\n"; 27$result_2 = mb_ereg_replace('123', 'abc', $string_ascii); 28var_dump(bin2hex($result_2)); 29 30echo "\n-- Multibyte string 1 --\n"; 31$regex1 = base64_decode('KOaXpeacrOiqnikuKj8oWzEtOV0rKQ=='); //Japanese regex in UTF-8 32$result_3 = mb_ereg_replace($regex1, '\\1_____\\2', $string_mb); 33var_dump(bin2hex($result_3)); 34 35echo "\n-- Multibyte string 2 --\n"; 36$regex2 = base64_decode('5LiW55WM'); 37$result_4 = mb_ereg_replace($regex2, '_____', $string_mb); 38var_dump(bin2hex($result_4)); 39 40echo "Done"; 41?> 42--EXPECT-- 43*** Testing mb_ereg_replace() : basic functionality *** 44 45-- ASCII string 1 -- 46string(16) "6162632020313233" 47 48-- ASCII string 2 -- 49string(14) "61626320646566" 50 51-- Multibyte string 1 -- 52string(72) "e697a5e69cace8aa9e5f5f5f5f5f31323334efbc95efbc96efbc97efbc98efbc99e38082" 53 54-- Multibyte string 2 -- 55string(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" 56Done 57