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

Powershell - Remove C++ comments from file

我是 powershell 的新手,需要一些帮助。我想使用替换功能从 C++ 源代码中删除所有注释。即单行和多行注释:

/*
    Comment here.
*/

// Comment here.

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

看看这个answer

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

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