Quick actions

cmd+k|ctrl+k

Navigation

Languages

test_preg_match_all

Snippet info

Language

Php

Visibility

public

Author

fenghestudio

Created

2019-09-17T02:12:26Z

Updated

2019-09-17T02:12:26Z

<?php

$str = <
<
<
FOO
a: 1
b: 2
c: 3
FOO;

preg_match_all('/(?P<
name>
\w+): (?P<
digit>
\d+)/', $str, $matches);

/* 下面代码在php 5.2.2(pcre 7.0)或更高版本下工作, 不过, 为了向后兼容
 * 推荐使用上面的方式. */
// preg_match_all('/(?<
name>
\w+): (?<
digit>
\d+)/', $str, $matches);

print_r($matches);

?>
INFO