echo '<pre>'; print_r(1); echo '</pre>'; <- select this
echo '<pre>'; print_r($temp); echo '</pre>'; <- select this without space
// echo '<pre>'; print_r($temp); echo '</pre>'; <- skip this
echo '<pre>'; print_r($temp3); echo '</pre>'; <- select this
print_r($temp1); <- select this
// print_r($temp11); <- skip this
print_r($temp2); <- select this without spaces
if (true) {
print_r($temp4); <- select this without spaces
}
我有一个打印语句的代码,我只需要选择非注释语句
这是正则表达式
^((?!\/\/\s?))(echo '<pre>';\s?)?(.+)?(print_r)(\.?)(\w+)?\((.+)?\);( echo '<\/pre>';)?
如何跳过空格?' print_r($temp4);'
或者我如何改变regex使其工作?你知道吗
如果有注释,这个正则表达式不会捕获行
(//, @*, /*, <!--)
否则它将捕获所有没有空格的内容,希望这能解决您的问题。你知道吗可能是这样的:
相关问题 更多 >
编程相关推荐