(.*)<\/\1>/', //'

An h2 header

Hello, world!

', //$matches); //print_r($matches); //preg_match_all('/<(.*)>(.*)<\/\1>/', //'

An h2 header

Hello, world!

', //$matches); //print_r($matches); //preg_match('/<(.*)>(.*)<\/\1>/', //'

An h2 header

Hello, world!

', //$matches, PREG_OFFSET_CAPTURE); //print_r($matches); //preg_match_all('/<(.*)>(.*)<\/\1>/', //'

An h2 header

Hello, world!

', //$matches, PREG_OFFSET_CAPTURE); //print_r($matches); //=====Illustrate a non-capturing group //preg_match('/(foo)(bar)(baz)/', //'foobarbaz', $matches); //print_r($matches); //preg_match('/(foo)(?:bar)(baz)/', //'foobarbaz', $matches); //print_r($matches); //=====Illustrate element optional, group capture not optional //This example matches "B", captures "" //preg_match('/(A?)B/', 'B', $matches); //print_r($matches); //But if "A" is there, the "AB" is matched, and "A" is captured //preg_match('/(A?)B/', 'AB', $matches); //print_r($matches); //Illustrate element not optional, group capture optional //This example matches "B", captures nothing //preg_match('/(A)?B/', 'B', $matches); //print_r($matches); //Here too, if "A" is there, "AB" is matched and "A" is captured //preg_match('/(A)?B/', 'AB', $matches); //print_r($matches); ?>