$htmltitle1 = "{Quit|Discontinue|Stop|Cease|Give Up} Tottenham Manager {HEY}"
$reg = "\{.*?\}"
$found = $htmltitle1 -match $reg
$spuntext = @()
If ($found)
{
([regex]$reg).matches($htmltitle1)
}
Run Code Online (Sandbox Code Playgroud)
我可以看到$ matches(下面)但是如何将每个匹配提取到$ spuntext数组中?大声笑我几个小时都在尝试不同的事情.
Groups : {{Quit|Discontinue|Stop|Cease|Give Up}}
Success : True
Captures : {{Quit|Discontinue|Stop|Cease|Give Up}}
Index : 0
Length : 37
Value : {Quit|Discontinue|Stop|Cease|Give Up}
Groups : {{HEY}}
Success : True
Captures : {{HEY}}
Index : 56
Length : 5
Value : {HEY}
Key : 0
Value : {Quit|Discontinue|Stop|Cease|Give Up}
Name : 0
Run Code Online (Sandbox Code Playgroud) powershell ×1