1
$installLocation = "C:\hello\world"
$packageName = "hello"
Write-Host "if ("$installLocation" -match '${packageName}|bla') {"
if ("$installLocation" -match '${packageName}|bla') {
Write-Host "hello";
}
if ("$installLocation" -match 'hello|bla') {
Write-Host "world";
}
當前結果如何查找變量並使用結果在PowerShell中進行匹配?
if (C:\hello\world -match 'hello|bla') {
world
預期成果
if (C:\hello\world -match 'hello|bla') {
hello
world