File: mb_ereg.phpt

package info (click to toggle)
php4 6%3A4.4.4-8%2Betch6
  • links: PTS
  • area: main
  • in suites: etch
  • size: 35,068 kB
  • ctags: 39,148
  • sloc: ansic: 340,486; php: 34,786; cpp: 10,150; sh: 9,010; lex: 2,180; yacc: 1,712; xml: 1,335; makefile: 559; awk: 466; java: 455; perl: 154
file content (47 lines) | stat: -rw-r--r-- 1,650 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--TEST--
mb_ereg()
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip mbstring not available');
function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
?>
--INI--
output_handler=
--FILE--
<?php
	mb_regex_set_options( '' );

	$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );

	function test_ereg( $test_enc, $pat, $str, $in_enc = 'EUC-JP' ) {
		mb_regex_encoding( $test_enc );
		$pat = mb_convert_encoding( $pat, $test_enc, $in_enc );
		$str = mb_convert_encoding( $str, $test_enc, $in_enc );

		printf( "(%d)%s\n", mb_ereg( $pat, $str, $reg ), ( is_array( $reg )? mb_convert_encoding( implode( ' ', $reg ), $in_enc, $test_enc ) : '' ) );
	} 
	function do_tests( $enc ) {
		test_ereg( $enc, 'abc ([a-z]+) ([a-z]+) ([a-z]+)$', "abc def ghi jkl" );
		$pat = '([-]+) ([ -]+)([-]+) ([-]+)$'; 
		test_ereg( $enc, $pat, '   ' );
		test_ereg( $enc, $pat, '   ' );
	}

	foreach( $encs as $enc ) {
		do_tests( $enc );
	}
?>

--EXPECT--
(15)abc def ghi jkl def ghi jkl
(27)        
(27)        
(15)abc def ghi jkl def ghi jkl
(27)        
(27)        
(15)abc def ghi jkl def ghi jkl
(27)        
(27)        
(15)abc def ghi jkl def ghi jkl
(39)        
(39)