left trim a string with "!"?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

left trim a string with "!"?

#1 Post by nnnmmm » 05 Sep 2017 03:35

LIB-STRING1.BAT is

Code: Select all

CALL :%1 %*
EXIT /B

:LTRIM
(@ECHO OFF
 SetLocal EnableExtensions EnableDelayedExpansion
    SET "STRING=!%~2%!
    FOR /F "TOKENS=* DELIMS= " %%A IN ("!STRING!") DO SET "STRING=%%A"
)
(Endlocal
   IF "%~2" NEQ "" SET "%~2=%STRING%"
)
EXIT /B


ZZZ=

Code: Select all

@ECHO OFF
SETLOCAL
  ECHO 1234567890
SET IN=  !  AAA
CALL "LIB-STRING1.BAT" LTRIM IN
ECHO %IN%
PAUSE

how can i fix ZZZ= for a string with "!"?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: left trim a string with "!"?

#2 Post by aGerman » 05 Sep 2017 09:26


Post Reply