How to remove characters from a string

Rebel_no_1
Rebel_no_1 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
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... :-)

"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
Should it not be clear from the link, here the needed commands in detail:
set stringA=%stringA:~3%
set stringB=%stringB:~,-3%
set stringC=%stringC:~3,-3%

Open in new window

But that should be obvious ;-).

Author

Commented:
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.

Author

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial