Powershell - 从文件中删除C ++注释

时间:2015-04-09 13:59:15

标签: regex powershell replace comments

我是PowerShell的新手,需要一些帮助。我想使用replace函数删除C ++源代码中的所有注释。这是单行和多行评论:

/*
    Comment here.
*/

// Comment here.

有人可以帮助我使用powershell正则表达式吗?

1 个答案:

答案 0 :(得分:1)

看看这个answer

在Powershell中,您也可以使用Regex.Replace,但方式略有不同:

[regex]::Replace($input, $pattern, $replacement)