Solved Passing varable not working for str validatio

July 14, 2011 at 04:05:27
Specs: Windows XP
Team.

set str1=test1234
set length1=3
set str1 = %str1:~0,-!length1!%
echo %str1%

Iam getting output str:~0,3 instead of test1. I cannot put the number 3 directly. Please help.


See More: Passing varable not working for str validatio

Report •

#1
July 14, 2011 at 15:25:31
✔ Best Answer
Test this:

@echo off
cls
setlocal enabledelayedexpansion

set str1=test1234
set length1=3
set str1=!str1:~0,-%length1%!
echo %str1%


Please come back & tell us if your problem is resolved.


Report •

#2
July 15, 2011 at 00:51:42
Many thanks for your help and Time Wahine. It works perfectly and this is what i required. Many thanks again.

Report •
Related Solutions


Ask Question