有没有一个优雅的一线做以下?
$myMatch = "^abc(.*)" $foo -match $myMatch $myVar = $matches[1]
我对$ myVar变量感兴趣…
只需使用-replace:
$foo = 'abcDEF' $myMatch = "^abc(.*)" $myVar = $foo -replace $myMatch,'$1' #$myVar contains DEF