欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Powershell小技巧之去除多余的空格

 更新時間:2014年10月02日 10:41:50   投稿:hebedich  
powershell可以幫助我們很方便的完成很多事情,今天我們就來看下如何使用powershell去除多余的空格,非常的簡單實用,有需要的朋友可以參考下

要去去除多余的空格,請嘗試下面正則表達式:

PS> '[ Man, it  works!  ]' -replace '\s{2,}', ' '
[ Man, it works! ] 

你也可以用這個方法轉換成固定格式的CSV表格:

PS> (qprocess) -replace '\s{2,}', ','
>tobias,console,1,3876,taskhostex.exe
>tobias,console,1,3844,explorer.exe
>tobias,console,1,4292,tabtip.exe

一旦變成CSV格式,你就可以使用ConvertFrom-Csv獲取該文本數(shù)據(jù)的對象:
 

PS> (qprocess) -replace '\s{2,}', ',' | ConvertFrom-Csv -Header Name, Session, ID, Pid, Process

Name  : >tobias
Session : console
ID   : 1
Pid   : 3876
Process : taskhostex.exe

Name  : >tobias
Session : console
ID   : 1
Pid   : 3844
Process : explorer.exe

Name  : >tobias
Session : console
ID   : 1
Pid   : 4292
Process : tabtip.exe 
(...)

支持所有PS版本

相關文章

最新評論