Display a character between two or more characters

Source: Internet
Author: User

CopyCode The Code is as follows:
:
: B
: C
: D
: E
: F
: Each letter occupies a line. ''I wonder if it can be implemented ..

@ Echo off
::
::
: Begin
CLS
Set STR = a B c d e f g h I j k l m n o p q r s t u v w x Y Z
Set input =
Set/P input = 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 s t u v w x Y Z
: Begin
CLS
Set flag = 0
Set Var =
Set input =
Set/P input = 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 conversion.
::
::
Setlocal enabledelayedexpansion

Set STR = a B c d e f g h I j k l m n o p q r s t u v w x Y Z
For % I in (% STR %) do set/a dec + = 1 & set % I =! Dec! & Set Str! Dec! = % I
Set en =
Set/P en = enter a letter range (for example, af ):
Set/A num1 =! % En :~ 0, 1% !, Num2 =! % En :~ -1%!
For/L % I in (% num1 %, 1, % num2 %) Do echo! STR % I!
Pause> NUL
Goto: EOF

@ Echo off
: It is achieved by comparing the internal encoding size of characters, with great limitations.
::
::
Setlocal enabledelayedexpansion

Set STR = a B c d e f g h I j k l m n o p q r s t u v w x Y Z
Set en =
Set/P en = enter a letter range (for example, 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
: Disadvantage: Slow speed
::
::
: Begin
Set/p a = "Old rule :"
Set STR = a B c d e f g h I j k l m n o p q r s t u v w x Y Z
For % I in (% STR %) Do echo % I | findstr [% :~ 0, 1%-% :~ -1%]
Pause
Goto begin

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.