powershell - PowerShell:获取两个字符串之间的数据

标签 powershell

我已经将下一个数据放入变量$ out中(类型为Object []):

Success...
Go!
0:#217> trace && .quit
   0x000 Subline         : _OK
   0x008 Timed      : NO
   0x016 Check     : _OK
   0x022 Post       : 
   0x030 Offset         : None
   0x038 Hint     : False
   0x050 NextHint    : False
quit:

我需要在字符串 0:#217> trace && .quit 退出之间提取文本:
我写:
[Regex]::Match($out, "(?<=.quit').+?(?=quit:)").Value

但这会将所需的数据提取到一行(字符串类型)而不是列(Object [])中。如何解决这个问题?

P.S.
我自己解决了这个问题,如下
([Regex]'(?is)(?:(?<=\.quit).+(?=quit:))').Match(($out -join "`n")).Value

但是,也许有更完美的方法可以做到这一点?

最佳答案

问题解决了

([Regex]'\s+0x([^q]+)').Match(($out -join "`n")).Value

关于powershell - PowerShell:获取两个字符串之间的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37193061/

相关文章:

powershell - 如何在 Powershell 中编辑 Windows 应用商店应用程序的 settings.dat 文件?

powershell - 获得独特的值(value)

Powershell try catch IOException DirectoryExist

powershell - 如何在powershell功能中启用OGV

json - ConvertTo-Json截断对象

c# - 在 C# 中执行 Powershell Cmdlet 代码

powershell - 在 powershell 中异步移动文件

api - Powershell Invoke-RestMethod

powershell - VMware Powercli快照

powershell - 如何使用 Powershell 在 Dropbox 中递归地忽略文件