1--TEST-- 2Testing mb_ereg_search() function 3--SKIPIF-- 4<?php 5if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); 6function_exists('mb_ereg_search') or die("skip mb_ereg_search() is not available in this build"); 7?> 8--FILE-- 9<?php 10 $str = "中国abc + abc ?!?!字符# china string"; 11 12 $reg = "\w+"; 13 14 mb_regex_encoding("UTF-8"); 15 16 mb_ereg_search_init($str, $reg); 17 $r = mb_ereg_search(); 18 19 if(!$r) 20 { 21 echo "null\n"; 22 } 23 else 24 { 25 $r = mb_ereg_search_getregs(); //get first result 26 do 27 { 28 var_dump($r[0]); 29 $r = mb_ereg_search_regs();//get next result 30 } 31 while($r); 32 } 33?> 34--EXPECT-- 35string(9) "中国abc" 36string(3) "abc" 37string(6) "字符" 38string(5) "china" 39string(6) "string" 40