Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use batch processing to remove all zeros before a specified character

Shulou Source: shulou.com Published: 2022-06-03 07:49:58 10月03日 Update

This article will explain in detail how to use batch processing to remove all zeros before specified characters. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

For example, text 1.txt:

Code:

0000acb0h

0b0c00a000s

0000h00ga00

A0000000

The zero before the an of all string characters in the text is removed by batch processing, and the output is as follows:

Code:

Acb0h

Bca000s

Hga00

A0000000

Requirements: the code is simple, efficient, universal, and no temporary files are generated.

Pusofalse:

The 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:

The 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 popular is that it is convenient to write and use.

At the same time, from another level, we are required to deal with specific problems. I believe no one will.

Write a code suitable for all such problems in order to solve a common problem.

Well, if you really want to do so, the loss of time will be an inestimable loss, I

And the loss will outweigh the gain.

This is the end of this article on "how to use batch processing to remove all zeros before specified characters". I hope the above content can be helpful to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.

Tags: Code character article question antecedent text more good practical ordinary concise loss outweighs gain reason content at the same time string level loss file article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi Shulou Information Redmi Linux