Batch Processing removes the code 0 before a specified character

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.