String Manipulation

String Substitution

SET Str="Hello, World"
ECHO %Str%
REM Replace all 'o' with 'X'
SET Str=%Str:o=X%
ECHO %Str%

Substring

REM Get string starting from the 5th position to the end.
SET mySubstring=This String will be cut.
ECHO %mySubstring%
SET mySubstring=%mySubstring:~5%
ECHO %mySubstring%

REM =================== OR ======================

REM Use CALL and SET commands to extract a substring with variable length.
SET start=5
SET length=12
SET string=This long string will be cutted.
CALL SET substring=%%string:~%start%,%length%%%
ECHO %substring%