Get the App
SLTechnology News&Howtos  ›  Development  › 

How to display two characters and the characters between them in batch processing

Shulou Source: shulou.com Published: 2022-06-03 06:30:13 09月19日 Update

This article mainly shows you "how to display a certain two characters and the characters between them". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn the article "how to display two characters and the characters between them".

The code is as follows:

:: for example, when I type af, it will show

:: a

:: b

:: c

:: d

:: e

:: f

:: each letter occupies a line.'I wonder if it can be realized.

@ echo off

::

::

: begin

Cls

Set str=a b c d e f g h i j k l m n o p q r st u v w x y z

Set input=

Set / p input= Please enter a letter range (such as af):

Call set str=%%str:%input:~0,1%=- ☆ input:~0,1%%%

Call set str=%%str:%input:~-1%=%input:~-1% ☆%

For / f "tokens=2 delims= ☆" I in ("str%") do set str=%%i

For I in (str%) do echo I

Pause

Goto begin

@ echo off

::

::

Set str=a b c d e f g h i j k l m n o p q r st u v w x y z

: begin

Cls

Set flag=0

Set var=

Set input=

Set / p input= Please enter a letter range (such as af):

For% I in (% str%) do call: pickup% I

: end

Pause

Goto begin

: pickup

If / I "% 1" = = "% input:~0,1%" set flag=1

If / I "% 1" = = "% input:~-1%" set flag=2

If flag% equ 1 echo 1

If flag% equ 2 echo 1&goto end

Goto: eof

@ echo off

Encode each element of the string before converting it

::

::

Setlocal enabledelayedexpansion

Set str=a b c d e f g h i j k l m n o p q r st u v w x y z

For% I in (% str%) do set/a dec+=1 & set% iConstrucdec! & set stringed declines%% I

Set en=

Set / p en= Please enter a letter range (such as af):

Set/a num 1 percent, enRom zero, zero zero, one percent, one hundred percent, one hundred percent!

For / l I in (num1%,1,%num2%) do echo! str%%i!

Pause > nul

Goto: eof

@ echo off

:: it is very limited to compare the size of the internal encoding of characters.

::

::

Setlocal enabledelayedexpansion

Set str=a b c d e f g h i j k l m n o p q r st u v w x y z

Set en=

Set / p en= Please enter a letter range (such as af):

Set str1=%en:~0,1%

Set str2=%en:~-1%

For I in (str%) do if I geq! str1! If I leq! str2! Echo I

Pause > nul

Goto: eof

@ echo off

Disadvantages: slow speed

::

::

: begin

Set / p a = "the old rules hee hee:"

Set str=a b c d e f g h i j k l m n o p q r st u v w x y z

For% I in (% str%) do echo%% I | findstr [% aVOR / 0min 1% Murray% aRom / 1%]

Pause

Goto begin

The above is all the contents of the article "how to display a certain two characters and the characters between them". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Characters letters input range two between content articles coding learning help hee hee very large line code elements size strings limitations easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei macOS Linux Xiaomi