给定此变量
$foo = help | Select-String powershell尝试拆分将失败
PS > $foo.split()
Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo]
does not contain a method named 'split'.
At line:1 char:1
+ $foo.split()
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound如何拆分这个变量?
发布于 2014-07-20 10:52:42
匹配行的字符串值位于MatchInfo对象的line属性中。
$foo.Line.split()发布于 2014-07-20 10:36:49
Split是一个字符串方法,因此必须在字符串上调用它。
[string] $foo = help | Select-String powershell或
$foo = help | Select-String powershell | Out-Stringhttps://stackoverflow.com/questions/24846685
复制相似问题