Following are the two characters. 1. {{ 2. }} I'm trying to find all the strings between these characters in the following file.
<add key="CSDFG_SqlServerFailOverInterval" value="{{environment}}"/>
<add key="CSDFG_JobResetInterval" value="600000"/>
<add key="FileTypeFilter" value="{{filetype}}"/>
and I'm using following powershell commands,
$x = C:\app.config
$s = Get-Content $x
$prog = [regex]::match($s,'{{([^/)]+)}}').Groups[1].Value
write-host $prog
and my output is just one string. it is not pulling all the strings. Can someone please suggest me how to get the all the strings. Thanks in advance.
[regex]::Match()
only returns the first match. Use [regex]::Matches()
to capture all matches:
$s = Get-Content 'C:\app.config'
[regex]::Matches($s, '{{([^/)]+)}}') |ForEach-Object { $_.Groups[1].Value }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With