返回重复表达式的集合

时间:2013-08-22 13:37:12

标签: regex powershell

我的来源是:

... <a href='...'>...</a> .... <a href='...'>....</a>  ...  <a href='...'>... </a> ...

<a href='(.*?)'>会给我第一个href值吗? (为了便于阅读,我省略了那些需要转义的内容,但我希望你知道我的意思。)有没有办法返回一个与模式匹配的集合?

1 个答案:

答案 0 :(得分:4)

$s = "tralala <a href='A'>A</a> blah <a href='BB'>BB</a>  blih <a href='CCC'>CCC</a>"
$matches = ($s | select-string "\<a.+?href.*?=.*?\'.*?'\>.*?\</a\>" -allmatches).matches
$matches | % { $_.Value }