批量替换多个不同的字符串 [英] batch replace multiple different strings

查看:183
本文介绍了批量替换多个不同的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现下面的解决方案可以替换字符串,但是我不完全理解.
如何更改代码以替换每行3个字符串?
我的更改(第12行和第13行)尚未生效.

I found that solution below to replace strings, but I do not fully understand it.
How do I have to change the code to replace 3 strings per line?
My changes (line 12 and 13) aren't working yet.

是否可以不运行第二和第三循环?

Is it possible without running a second and third loop?

ECHO off
SETLOCAL enabledelayedexpansion

SET source="C:\source.srt"
SET target="C:\target.srt"

IF EXIST %target% DEL /f %target%

FOR /f "delims=" %%i IN ('FINDSTR . %source%') DO (
   SET line=%%i
   SET line=!line:ö=oe!
   SET line=!line:ä=ae!
   SET line=!line:ü=ue!
   ECHO !line! >> %target%
)

推荐答案

您不想使用 sed ?那将是一个简单的单行命令.

Don't you want to use sed? There it would be a simple one line command.

sed -e 's/ö/oe/g' -e 's/ä/ae/g' -e 's/ü/ue/g' source.srt

这篇关于批量替换多个不同的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆