I have tried various different combos and already checked other similar posts, but can't find my answer. I have a .config file and I need to exclude the comments from the file when I do my search, something like below:
(Get-Content C:\Path\File.config -Raw) | Select-String '(<!--((?!-->)(.|\n))*-->)' -AllMatches
I have tried the below regex as well:
(?smi)^\<!--.*?--\>?
Both of these work on regex101 and regex.net, but does not work at all with Powershell. This is how my .config file looks:
Test
<!--<add name= />
<add name= />
<add name= />-->
<add name= />
<!--<add name= />
<add name= />-->
Test
Test
I have made sure I am using -Raw with my get-content and also tried out-string. These regex work everywhere except, powershell. Your help is duly appreciated