1--TEST-- 2Testing mb_ereg() named subpatterns 3--EXTENSIONS-- 4mbstring 5--SKIPIF-- 6<?php 7function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build"); 8?> 9--FILE-- 10<?php 11 mb_regex_encoding("UTF-8"); 12 mb_ereg('(?<wsp>\s*)(?<word>\w+)', ' 中国', $m); 13 var_dump($m); 14 mb_ereg('(?<wsp>\s*)(?<word>\w+)', '国', $m); 15 var_dump($m); 16 mb_ereg('(\s*)(?<word>\w+)', ' 中国', $m); 17 var_dump($m); 18?> 19--EXPECT-- 20array(5) { 21 [0]=> 22 string(8) " 中国" 23 [1]=> 24 string(2) " " 25 [2]=> 26 string(6) "中国" 27 ["wsp"]=> 28 string(2) " " 29 ["word"]=> 30 string(6) "中国" 31} 32array(5) { 33 [0]=> 34 string(3) "国" 35 [1]=> 36 bool(false) 37 [2]=> 38 string(3) "国" 39 ["wsp"]=> 40 bool(false) 41 ["word"]=> 42 string(3) "国" 43} 44array(3) { 45 [0]=> 46 string(8) " 中国" 47 [1]=> 48 string(6) "中国" 49 ["word"]=> 50 string(6) "中国" 51} 52