Annotation of embedaddon/php/ext/mbstring/tests/mb_ereg_match_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_ereg_match() function : basic functionality
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_ereg_match') or die("skip mb_ereg_match() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : bool mb_ereg_match(string $pattern, string $string [,string $option])
11: * Description: Regular expression match for multibyte string
12: * Source code: ext/mbstring/php_mbregex.c
13: */
14:
15: /*
16: * Test basic functionality of mb_ereg_match
17: */
18:
19: mb_internal_encoding('UTF-8');
20: mb_regex_encoding('UTF-8');
21:
22: echo "*** Testing mb_ereg_match() : basic functionality ***\n";
23: $string_ascii = b'abc def, 0123456789';
24: $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
25:
26: //will return true as pattern matches from start of string
27: echo "\n-- ASCII string 1 --\n";
28: var_dump(mb_ereg_match(b'.*def', $string_ascii));
29:
30: //will return false as pattern would match half way through string
31: echo "\n-- ASCII string 2 --\n";
32: var_dump(mb_ereg_match(b'def', $string_ascii));
33:
34: echo "\n-- Multibyte string 1 --\n";
35: $regex1 = base64_decode('5pel5pys6KqeKC4qKT9bMS05XSs=');
36: var_dump(mb_ereg_match($regex1, $string_mb, b'i'));
37:
38: echo "\n-- Multibyte string 2 --\n";
39: $regex2 = base64_decode('5LiW55WM');
40: var_dump(mb_ereg_match($regex2, $string_mb));
41:
42: echo "Done";
43: ?>
44: --EXPECTF--
45:
46: *** Testing mb_ereg_match() : basic functionality ***
47:
48: -- ASCII string 1 --
49: bool(true)
50:
51: -- ASCII string 2 --
52: bool(false)
53:
54: -- Multibyte string 1 --
55: bool(true)
56:
57: -- Multibyte string 2 --
58: bool(false)
59: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>