PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
637 stars 219 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 1 year ago

davnex commented 1 year 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 1 year ago

I don't understand why this was opened here.