1
0
mirror of https://github.com/php/php-src.git synced 2026-04-16 20:41:18 +02:00
Files
archived-php-src/ext/mbstring/tests/mb_ereg_named_subpatterns.phpt
ju1ius 212f56b7ca adds support for named captures to mb_ereg & mb_ereg_search
`mb_ereg`, `mb_ereg_search_regs` & `mb_ereg_search_getregs`
returned only numbered capturing groups.
Now they return both numbered and named capturing groups.
Fixes Bug #72704.
2018-07-06 23:34:54 +02:00

51 lines
902 B
PHP

--TEST--
Testing mb_ereg() named subpatterns
--SKIPIF--
<?php
if (!extension_loaded('mbstring')) die('skip mbstring not enabled');
function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
?>
--FILE--
<?php
mb_regex_encoding("UTF-8");
mb_ereg('(?<wsp>\s*)(?<word>\w+)', ' 中国', $m);
var_dump($m);
mb_ereg('(?<wsp>\s*)(?<word>\w+)', '国', $m);
var_dump($m);
mb_ereg('(\s*)(?<word>\w+)', ' 中国', $m);
var_dump($m);
?>
--EXPECT--
array(5) {
[0]=>
string(8) " 中国"
[1]=>
string(2) " "
[2]=>
string(6) "中国"
["wsp"]=>
string(2) " "
["word"]=>
string(6) "中国"
}
array(5) {
[0]=>
string(3) "国"
[1]=>
bool(false)
[2]=>
string(3) "国"
["wsp"]=>
bool(false)
["word"]=>
string(3) "国"
}
array(3) {
[0]=>
string(8) " 中国"
[1]=>
string(6) "中国"
["word"]=>
string(6) "中国"
}