For example, extract 1.txt:
Code:
0000acb0h
0b0c00a000s
2017h00ga00
A0000000
After batch processing, the 0 before all character strings a in the text is removed and the output is as follows:
Code:
Acb0h
Bca000s
Hga00
A0000000
Requirements: the code is concise, efficient, and common, and no temporary files are generated.
Pusofalse:Copy codeThe Code is as follows: @ echo off
For/f "delims =" %. in (1.txt) do (
Set "str = % ."
Call, set "str = % str: * a = %"
For/f "delims = a" % {in ("%.") do (
Set "var = % {"
Call, echo. % var: 0 = % a % str %
))
Pause> nul
Batman:Copy codeThe Code is as follows: @ echo off
For/f "tokens = 1, 2 delims = a" % I in (1.txt) do (
If "% j" neq ""(
Set "str = % I"
Call, set "str = % str: 0 = %"
Call, echo % str % a % j
) Else (
Echo a % I
)
)
Pause> nul
The reason why batch processing is so favored is that it is easy to write and use,
At the same time, on the other hand, we need to treat specific problems, and no one will trust us.
Write a code suitable for solving all the common problems.
To do so, the loss of time will be immeasurable.
We will also lose the candle.