Computing.Net > Forums > Disk Operating System > String Trim

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

String Trim

Reply to Message Icon

Name: Darth Sidious
Date: September 19, 2009 at 21:40:25 Pacific
OS: Windows XP
Subcategory: General
Comment:

String=ABCDE
Echo %String:~0,1%
This Returns "A"

I want to substitute one or all of the numbers in the trim function with a predefined variable or another string.

(ie) lets assume I have a %Counter% string.
So If counter = 2

If I was to substitute this into the above string It would look like this.

Echo %String:~0,%Counter%%

or

%String:~0,!Counter!%

The result you want is "AB", but the output can't be processed as the syntax of the way that the %counter% is entered is not correct.

Can you help me correct the syntax so that it can process the request?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 20, 2009 at 02:35:32 Pacific
Reply:

Wrong forum. This has nothing to do with DOS.

=========================
@echo off & setLocal EnableDELAYedExpansion

set str=ABCDE
set N=2
echo !str:~0,%N%!


=====================================
Helping others achieve escape felicity

M2


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: String Trim

String manipulation www.computing.net/answers/dos/string-manipulation/11933.html

how to write a string to a txt file www.computing.net/answers/dos/how-to-write-a-string-to-a-txt-file/11890.html

Automatic substition of strings using dos programs www.computing.net/answers/dos/automatic-substition-of-strings-using-dos-programs/3787.html