Link to home
Create AccountLog in
Avatar of Rebel_no_1
Rebel_no_1Flag 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.
Avatar of Rebel_no_1
Rebel_no_1
Flag of China image

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
Avatar of fredvr666
fredvr666

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.
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.