Quick actions

cmd+k|ctrl+k

Navigation

Languages

test_preg_match

Snippet info

Language

Php

Visibility

public

Author

fenghestudio

Created

2019-09-19T04:10:09Z

Updated

2019-09-19T04:10:09Z

<?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