How to realize the function of string interception in batch processing
This article will explain in detail how to achieve string interception in batch processing. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The code is as follows:
:: code by lxmxn @ cn-dos.net.
Objective: to help beginners better understand the function of variable character interception.
:: Date 2006-12-16.
:: description: some variables are empty after intercepting, which is normal.
::
@ echo off&setlocal EnableDelayedexpansion
:: set the value of variable var:
Set var=0123456789ABCDEF
Call: begin
For / l% an in (1meme 3je 15) do (
For / l% b in (1meme 4mem15) do (
Call: printf% a% b
)
)
Call: begin
For / l% an in (1meme 4je 15) do (
For / l% b in (- 1) do (
Call: printf% a% b
)
)
Call: begin
For / l% an in (- 2 mai Yu 3 mi mi 15) do (
For / l% b in (1meme 4mem15) do (
Call: printf% a% b
)
)
Call: begin
For / l% an in (- 1) do (
For / l% b in (- 2 mai Yu 3 mi mi 15) do (
Call: printf% a% b
)
)
Pause
Endlocal&cls&echo.
Echo demo is over, any key to exit.
Pause > nul
Goto: eof
:: output result:
: printf
The character intercepted by echo% var:~%1,%2%% is:! var:~%1,%2!
Goto: eof
:: clean the screen:
: begin
Echo\ & pause&cls&echo.
The value of the echo variable var is:% var%
Echo.
Goto: eof
This is the end of this article on "how to intercept strings in batch processing". 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.