[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. REM 文件路径
  3. set "txt=123.txt"
  4. powershell -version 2.0 -c "(Get-Content '%txt%') | foreach {($_ -replace '(?=[^\s])(?<=[^\s])','】【' -replace '(?<=^\s*)','【' -replace '【(?=\s)','') + '】'} | Out-File 'new.txt'"
  5. pause&exit
复制代码
文字保存为123.txt,ANSI编码
代码保存为bat,ANSI编码
生成new.txt

TOP

回复 4# 188388
  1. @echo off
  2. REM 文件路径
  3. set "txt=123.txt"
  4. powershell -version 2.0 -c "(Get-Content '123.txt') -replace '(?=[^\n])','】【' -replace '^】','' -replace '(?<=\S)(?=\s*$)','】' | Out-File 'new.txt'"
  5. pause&exit
复制代码

TOP

用楼上的方法很简单,搞复杂了
  1. @echo off
  2. REM 文件路径
  3. set "txt=123.txt"
  4. powershell -version 2.0 -c "(Get-Content '123.txt') -replace '(.)','【$1】' | Out-File 'new.txt'"
  5. pause&exit
复制代码

TOP

返回列表