我有以下腳本,由行會行發現在一個CSV文件中的空格PowerShell的突出空白髮現
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Retain blank space."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Delete blank space."
$n = @()
$f = Get-Content C:\MyPath\*.csv
foreach($item in $f) {
if($item -like "* *"){
$res = $host.ui.PromptForChoice("Title", "want to keep the blank on this line? `n $item", [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no), 0)
switch ($res)
{
0 {$n+=$item}
1 {$n+=$item -replace ' '}
}
} else {
$n+=$item -replace ' '
}
}
$n | Set-Content C:\MyPath\*.csv
的問題是:當有找了個空位,我怎麼能突出在哪裏排隊或在那裏放置顏色,什麼可以減輕發現它的過程?
編輯:不想改變文件或文本,這應該只顯示在PowerShell的控制檯或在ISE的窗口彈出。
這將是您正在使用,以查看該文件的編輯器的功能。不是Powershell。 – EBGreen
用一個特殊的字符替換空格,例如'§',這將很容易找到它然後 –
我得到控制檯中的字符串。不是在一些編輯@EBGreen – CM2K