diff --git a/NameRegex.ps1 b/NameRegex.ps1 index acdf21e..8d1f5ab 100644 --- a/NameRegex.ps1 +++ b/NameRegex.ps1 @@ -6,8 +6,11 @@ # Regex 可輸入複數個 Write-Host $Str $Regex | % { - $key = if ($_ -match "\(\?\<(.*?)\>") { $Matches[1] } - if (-not($key)) { Write-Error "$_ 沒有定義(?)" } + $key = if ($_ -match "\(\?\<(.*?)\>") { + $Matches[1] + } else { + Write-Error "$_ 沒有定義(?)" + } if ($Str -match $_ -and($key)) { $Result = @{ $key = $Matches[$key]