xref: /php-src/ext/mbstring/tests/mb_ereg.phpt (revision 39131219)
1--TEST--
2mb_ereg()
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
8?>
9--INI--
10output_handler=
11--FILE--
12<?php
13    mb_regex_set_options( '' );
14
15    $encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
16
17    function test_ereg( $test_enc, $pat, $str, $in_enc = 'EUC-JP' ) {
18        mb_regex_encoding( $test_enc );
19        $pat = mb_convert_encoding( $pat, $test_enc, $in_enc );
20        $str = mb_convert_encoding( $str, $test_enc, $in_enc );
21        printf( "(%d)%s\n", mb_ereg( $pat, $str, $reg ), ( is_array( $reg )? bin2hex(mb_convert_encoding( implode( ' ', $reg ), $in_enc, $test_enc )) : '' ) );
22    }
23    function do_tests( $enc ) {
24        test_ereg( $enc, 'abc ([a-z]+) ([a-z]+) ([a-z]+)$', "abc def ghi jkl" );
25        $pat = '([��-��]+) ([ ��-��]+)([��-��]+) ([��-��]+)$';
26        test_ereg( $enc, $pat, '���� ������ ������ ����' );
27        test_ereg( $enc, $pat, '�������� ������ ���� ���' );
28    }
29
30    foreach( $encs as $enc ) {
31        do_tests( $enc );
32    }
33?>
34--EXPECT--
35(1)6162632064656620676869206a6b6c2064656620676869206a6b6c
36(1)a3e1a3e2a3e320a4a2a4aaa4a420a4aba4b3a4ca20a4efa4f1a4f320a3e1a3e2a3e320a4a2a4aaa4a420a4ab20a4b3a4ca20a4efa4f1a4f3
37(1)a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab20a4ada4ab20a4f2a4f020a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab2020a4ada4ab20a4f2a4f0
38(1)6162632064656620676869206a6b6c2064656620676869206a6b6c
39(1)a3e1a3e2a3e320a4a2a4aaa4a420a4aba4b3a4ca20a4efa4f1a4f320a3e1a3e2a3e320a4a2a4aaa4a420a4ab20a4b3a4ca20a4efa4f1a4f3
40(1)a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab20a4ada4ab20a4f2a4f020a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab2020a4ada4ab20a4f2a4f0
41(1)6162632064656620676869206a6b6c2064656620676869206a6b6c
42(1)a3e1a3e2a3e320a4a2a4aaa4a420a4aba4b3a4ca20a4efa4f1a4f320a3e1a3e2a3e320a4a2a4aaa4a420a4ab20a4b3a4ca20a4efa4f1a4f3
43(1)a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab20a4ada4ab20a4f2a4f020a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab2020a4ada4ab20a4f2a4f0
44(1)6162632064656620676869206a6b6c2064656620676869206a6b6c
45(1)a3e1a3e2a3e320a4a2a4aaa4a420a4aba4b3a4ca20a4efa4f1a4f320a3e1a3e2a3e320a4a2a4aaa4a420a4ab20a4b3a4ca20a4efa4f1a4f3
46(1)a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab20a4ada4ab20a4f2a4f020a3eda3faa3f8a3e6a3f020a4a6a4aaa4ab2020a4ada4ab20a4f2a4f0
47