【发布时间】:2015-01-09 22:22:56
【问题描述】:
我想将匹配项收集到特定字符串中的正则表达式中,并将它们放入数组中。
这是迄今为止我的代码的简化。
$myString = <p>a bunch of html</p> <a href="example.com/number1?ID=2014-89463">go</a>
$myMatches = $myString -match "\d{4}-\d{5}"
Write-Host $myMatches
$myMatches 正在返回整个字符串,但我想要的是让 $myMatches 返回为 2014-89463(以及其他任何匹配项,还有更多)。
另外,$myString 实际上是一个字符串数组,每个字符串都与上面列出的相似。
感谢您的帮助!
【问题讨论】:
标签: regex parsing powershell