我在解析PowerShell中的一些字符串数据时遇到问题,需要一点帮助。基本上我有一个不输出对象的应用程序命令,而是字符串数据。Powershell - 搜索字符串,删除多余的空白,打印第二个字段
a = is the item I'm searching for
b = is the actual ouput from the command
c = replaces all the excess whitespace with a single space
d = is supposed to take $c "hostOSVersion 8.0.2 7-Mode" and just print "8.0.2 7-Mode"
但是,$ d不起作用,它只是打印与$ c相同的值。我是一个UNIX家伙,在一个awk语句中这很容易。如果你知道如何在一个很好的命令中做到这一点,或者告诉我下面的$ d语法有什么问题。
$a = "hostOSVersion"
$b = "hostOSVersion 8.0.2 7-Mode"
$c = ($a -replace "\s+", " ").Split(" ")
$d = ($y -replace "$a ", "")
谢谢主席先生,那第二个单线程做了诀窍。 – user1403741