3
我有一個pacfile,我試圖更新並需要刪除兩個字符串之間的內容;字符串本身應保持:刪除2行之間的內容
// OFFICE 365 DIRECT ACCESS
和
// END OFFICE 365 DIRECT ACCESS
例如:
// OFFICE 365 DIRECT ACCESS
if (isInNet(hostip, "23.103.132.0","255.255.252.0") || //EOP
isInNet(hostip, "23.103.136.0","255.255.248.0") || //EOP
isInNet(hostip, "23.103.144.0","255.255.240.0") || //EOP
isInNet(hostip, "23.103.191.0","255.255.255.0") || //EOP
// END OFFICE 365 DIRECT ACCESS
我想刪除的頂部和底部線之間的線
$Pacfile = Get-ChildItem .\o365.pac | Get-Content -Raw
$startstring= " \/\/ OFFICE 365 DIRECT ACCESS(.*?)\/\/END OFFICE 365 DIRECT ACCESS"
$NewPacfile = [regex]::match($Pacfile, $startstring).Groups[1].value
$NewPacfile
你可以做一個替換。將start * end替換爲startend。 –