如何用正则表达式匹配到PHP多行注释?
3个回答
展开全部
<?php
$str = '
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/';
preg_match_all('|/\*.*?\*/|is', $str, $matches);
print_r($matches);
exit;
$str = '
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/';
preg_match_all('|/\*.*?\*/|is', $str, $matches);
print_r($matches);
exit;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
正则
/\/\*[\s\S]\*\//U
/\/\*[\s\S]\*\//U
更多追问追答
追问
也不能用啊
我想把那些注释用正则给找出来
追答
$str= file_get_contents('./9.php');
preg_match_all('/\/\*[\s\S]*\*\//U',$str,$matches);
var_dump($matches);
下面是9.php文件内容
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询