Avatar of Rebel_no_1
Rebel_no_1
Flag for China asked on

How to remove characters from a string

I hope I can explain this properly as this is an extremely basic question.

Three DOS environment variables gets generated by a bat file. For example:
STRINGA=1234567890
STRINGB=1234567890
STRINGC=1234567890

A) What command must I run to remove the first three characters form STRINGA?

B) What command must I run to remove the last three characters from STRINGB?

C) What command must I run to remove the first and last three characters from STRINGC?

I want to end up with:

STRINGA=4567890
STRINGB=1234567
STRINGC=4567

Please note that the three variables may be letters or characters.
Microsoft DOSOperating Systems

Avatar of undefined
Last Comment
Rebel_no_1

8/22/2022 - Mon
Rebel_no_1

ASKER
The script would look something like this:

::#############################################
Set STRINGA=1234567890
Set STRINGB=1234567890
Set STRINGC=1234567890

(Command to remove 123 from STRINGA)
(Command to remove 890 from STRINGB)
(Command to remove 123890 from STRINGC)

ECHO %STRINGA%
ECHO %STRINGB%
ECHO %STRINGC%

::#############################################

The three ECHO's should yield the new environment values. Ok, I'm sure this is 100% clear now... :-)

SOLUTION
fredvr666

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Rebel_no_1

ASKER
Thank you. I prefer answers to be posted directly and have therefore split the points between you two. Both of you are 100% correct in your answers though. Thank you, your help is always very much appreciated.
Rebel_no_1

ASKER
Thank you for the extra info Qlemo. I will definitely consider that in the future. I believe my judgement was pretty good considering that I did not know EE's policies. In future there will be more than a one point difference. :-) Still, thanks to both of you.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes