1--TEST--
2Test preg_match() function : basic functionality
3--FILE--
4<?php
5$string = 'Hello, world. [*], this is \ a string';
6
7var_dump(preg_match('/^[hH]ello,\s/', $string, $match1));							//finds "Hello, "
8var_dump($match1);
9
10var_dump(preg_match('/l^o,\s\w{5}/', $string, $match2, PREG_OFFSET_CAPTURE));				// tries to find "lo, world" at start of string
11var_dump($match2);
12
13var_dump(preg_match('/\[\*\],\s(.*)/', $string, $match3));							//finds "[*], this is \ a string";
14var_dump($match3);
15
16var_dump(preg_match('@\w{4}\s\w{2}\s\\\(?:\s.*)@', $string, $match4, PREG_OFFSET_CAPTURE, 14));	//finds "this is \ a string" (with non-capturing parentheses)
17var_dump($match4);
18
19var_dump(preg_match('/hello world/', $string, $match5));							//tries to find "hello world" (should be Hello, world)
20var_dump($match5);
21?>
22--EXPECT--
23int(1)
24array(1) {
25  [0]=>
26  string(7) "Hello, "
27}
28int(0)
29array(0) {
30}
31int(1)
32array(2) {
33  [0]=>
34  string(23) "[*], this is \ a string"
35  [1]=>
36  string(18) "this is \ a string"
37}
38int(1)
39array(1) {
40  [0]=>
41  array(2) {
42    [0]=>
43    string(18) "this is \ a string"
44    [1]=>
45    int(19)
46  }
47}
48int(0)
49array(0) {
50}
51