PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
613 stars 207 forks source link

> I think your regex has multiple issues. I don't have time at the moment to really dig into it, but wanted to offer an alternative approach. #2082

Closed davnex closed 9 months ago

davnex commented 9 months ago
          > I think your regex has multiple issues. I don't have time at the moment to really dig into it, but wanted to offer an alternative approach.
switch -regex ($vssadmin){
    "^\w.*'(?<Name>.*)'$" {$ht = @{Name = $matches.name}}
    "^\s+(?<Name>\w[\w\s]*): (?<Value>.*)$" {
        $ht.Add($matches.Name,$matches.Value)
        if($matches.Name -like '*err*'){
            [PSCustomObject]$ht
        }
    }
}

I miss some output with this code

Originally posted by @B-Art in https://github.com/PowerShell/PowerShell/issues/19754#issuecomment-1579286313

andyleejordan commented 9 months ago

I don't understand why this was opened here.