201
General Software Discussion / Re: Extract REGEX matches from multiple text files
« on: August 03, 2018, 05:15 PM »
Can you explain please word by word this bit:
$items = Get-ChildItem -Path *.txt # *.txt , *.foo , *.whatever
for ($i = 0; $i -lt $items.Count; $i++) {
Select-String -Path $items[$i] -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } >> $outfile
}
Also, I need to append to the output file several regex matches/returns, how do I do that?
Also, if I specify a regex match, how do I specify what I want to be returned from this match?
$items = Get-ChildItem -Path *.txt # *.txt , *.foo , *.whatever
for ($i = 0; $i -lt $items.Count; $i++) {
Select-String -Path $items[$i] -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } >> $outfile
}
Also, I need to append to the output file several regex matches/returns, how do I do that?
Also, if I specify a regex match, how do I specify what I want to be returned from this match?