0

I'm new to powershell and need some help. I want to use the replace function to remove all the comments from C++ source code. That is single and multiline comments:

/*
    Comment here.
*/

// Comment here.

Can someone help me with the powershell regex for this?

goocreations
  • 2,768
  • 7
  • 36
  • 56
  • Powershell regular expressions are not in any way special. Have you tried simply using the regex somebody else has written) (Regexes that match C-style language comments have been written, you will find any number of examples.) – Tomalak Apr 09 '15 at 14:03
  • http://stackoverflow.com/search?q=[regex]+[javascript]+comments http://stackoverflow.com/search?q=[regex]+[java]+comments http://stackoverflow.com/search?q=[regex]+[c]+comments take a look at any of these – Tomalak Apr 09 '15 at 14:10

1 Answers1

2

Take a look at this answer.

In Powershell you can also use Regex.Replace but in a slightly different way:

[regex]::Replace($input, $pattern, $replacement)
Community
  • 1
  • 1
Rubanov
  • 3,508
  • 1
  • 34
  • 33