我有一个文本文件,其内容如下:
我看到字符串有替换函数,可以将
testA=foo
testB=foobar
testC=Whatever
现在我想要提取testB
的值,也就是foobar
。使用我当前的PowerShell命令,我只能得到整行的内容:
testB=foobar
我的命令是:
Select-String -Path .\test.txt -Pattern "testB=" -List
我看到字符串有替换函数,可以将
testB=
替换为空字符串,但我不知道如何实现。
.Matches.Groups[1].Value
后面添加.Trim()
即可。 - Martin Brandl