1--TEST--
2mb_ereg_replace() with named subpatterns
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip mbstring not available');
6function_exists('mb_ereg_replace') or die("skip mb_ereg_replace() is not available in this build");
7?>
8--FILE--
9<?php
10    mb_regex_set_options('');
11    // \k<word> syntax
12    echo mb_ereg_replace('(?<a>\s*)(?<b>\w+)(?<c>\s*)', '\k<a>_\k<b>_\k<c>', 'a b c d e' ), "\n";
13    // \k'word' syntax
14    echo mb_ereg_replace('(?<word>[a-z]+)',"<\k'word'>", 'abc def ghi'), PHP_EOL;
15    // numbered captures with \k<n> syntax
16    echo mb_ereg_replace('(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(\10)', '\k<0>-\k<10>-', '123456789aa'), PHP_EOL;
17    // numbered captures with \k'n' syntax
18    echo mb_ereg_replace('(1)(2)(3)(4)(5)(6)(7)(8)(9)(a)(\10)', "\k'0'-\k'10'-", '123456789aa'), PHP_EOL;
19    // backref 0 works, but 01 is ignored
20    echo mb_ereg_replace('a', "\k'0'_\k<01>", 'a'), PHP_EOL;
21    // Numbered backref is ignored if named backrefs are present
22    echo mb_ereg_replace('(?<a>A)\k<a>', '-\1-', 'AA'), PHP_EOL;
23    // An empty backref is ignored
24    echo mb_ereg_replace('(\w)\1', '-\k<>-', 'AA'), PHP_EOL;
25    // An unclosed backref is ignored
26    echo mb_ereg_replace('(?<a>\w+)', '-\k<a', 'AA'), PHP_EOL;
27?>
28--EXPECT--
29_a_ _b_ _c_ _d_ _e_
30<abc> <def> <ghi>
31123456789aa-a-
32123456789aa-a-
33a_\k<01>
34-\1-
35-\k<>-
36-\k<a
37