【发布时间】:2010-12-03 05:19:56
【问题描述】:
我需要将单行 cmets (//...) 转换为块 cmets (/*...*/)。我在下面的代码中几乎完成了这一点;但是,我需要跳过任何单行注释的功能已经在块注释中。目前它匹配任何单行注释,即使单行注释在块注释中。
## Convert Single Line Comment to Block Comments
function singleLineComments( &$output ) {
$output = preg_replace_callback('#//(.*)#m',
create_function(
'$match',
'return "/* " . trim(mb_substr($match[1], 0)) . " */";'
), $output
);
}
【问题讨论】: