您现在的位置是:网站首页> 编程资料编程资料
Powershell小技巧之去除多余的空格_PowerShell_
2023-05-26
321人已围观
简介 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获取该文本数据的对象:
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版本
您可能感兴趣的文章:
相关内容
- Powershell小技巧之创建短网址_PowerShell_
- Powershell小技巧之查找脚本中的函数_PowerShell_
- Powershell小技巧之保存服务信息_PowerShell_
- Windows Powershell调用静态方法_PowerShell_
- Windows Powershell方法(对象能做什么)_PowerShell_
- Windows Powershell属性:描述对象是什么_PowerShell_
- Windows Powershell对象=属性+方法_PowerShell_
- Windows Powershell扩展类型系统_PowerShell_
- Windows Powershell导出管道结果_PowerShell_
- Powershell小技巧--远程对比服务配置_PowerShell_
