PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,595 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Why doesn't it split/ remove the other two values in front of the searched value?
I only need the value after ttt.
Auto Fahrrad Roller
------------------ -------------------- --------------------------------------------------------------------------------
HA_123 79777 ttt2345
HA_123 79778 ttt4567
I think I'd do it differently:
$regex = "[^\s]+\s+[^\s]+\s+ttt(\d+)" # Not Whitspace / Whitespace / Not Whitspace / Whitespace ttt digits
$filePath = "C:\Users\zippi\Desktop\PowershellTest"
$global:Ids = $null
Get-ChildItem $filePath -Filter *.txt -Recurse |
ForEach-Object {
Get-Content $_.FullName |
ForEach-Object{
if($_ -match $regex){
$Ids += $matches[1]
}
}
}