test_preg_match
<?php
$str = 'foobar: 2008';
preg_match('/(?P<
name>
\w+): (?P<
digit>
\d+)/', $str, $matches);
/* 下面例子在php 5.2.2(pcre 7.0)或更新版本下工作, 然而, 为了后向兼容, 上面的方式是推荐写法. */
// preg_match('/(?<
name>
\w+): (?<
digit>
\d+)/', $str, $matches);
print_r($matches);
?>
INFO