Extract string from text file via Powershell
问题 I have been trying to extract certain values from multiple lines inside a .txt file with PowerShell. Host Class INCLUDE vmware:/?filter=Displayname Equal "server01" OR Displayname Equal "server02" OR Displayname Equal "server03 test" This is what I want : server01 server02 server03 test I have code so far : $Regex = [Regex]::new("(?<=Equal)(.*)(?=OR") $Match = $Regex.Match($String) 回答1: You may use [regex]::matches($String, '(?<=Equal\s*")[^"]+') See the regex demo. See more ways to extract