How to replace Strings in Windows Batch file

前端 未结 4 551
误落风尘
误落风尘 2020-12-22 08:20

I would like to replace the following String in a file:

android:versionName=\"anyStringHere\" >

*anyStringHere represents any possible s

4条回答
  •  攒了一身酷
    2020-12-22 09:06

    This is a robust solution that retains all formatting. It uses a helper batch file called repl.bat - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

    Place repl.bat in the same folder as the batch file or in a folder that is on the path.

    type "file.txt" | repl "(public static String CONST = \q).*(\q.*)" "$1def$2" x >"newfile.txt"
    

提交回复
热议问题