1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
/* ----------------------------------------
 *       正規表現のpreg_match_allの例
 *
 *  作成: 2015.07.23 yoshi of CXMedia Inc.
 * ---------------------------------------- */
header("Content-type:text/plain; charset=UTF-8");

$str "/* first comment */  not comment  /* second comment */";
//「#」のデリミタ利用で、文字の「/」をエスケープ処理不要とし、最短一致の繰り返し処理
preg_match_all("#/\*.*?\*/#",$str,$matches);
echo 
"\n[result]\n";
print_r($matches);
?>