parse a string

Microsoft Windows xp professional w/serv...
August 12, 2010 at 06:55:21
Specs: Windows XP
I want to write a batch file which I can run against a text file which will capture the number in front of a colon on a line in the text file.

This is an example of the line in the file-
206: ProfileImagePath Reg_Expand_sz

I want to capture the number in front of the : in a variable or text file. The number varies in length.


See More: parse a string

Report •

#1
August 12, 2010 at 10:29:41
Is there just ONE line with a number followed by a colon?


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

M2


Report •

#2
August 12, 2010 at 11:38:06
Yes. I've managed to parse it out and put the line in a text file. The problem is that the number in front of the colon might be anywhere from 1 -5 digits long.

Report •

#3
August 12, 2010 at 21:48:31
@echo off
for /f "tokens=1 delims=:" %%a in (string.txt) do ( set code=%%a )
cls
echo %code%
pause

Report •

Related Solutions

#4
August 13, 2010 at 05:35:45
Great! This is much nicer than how I was doing it

Report •

Ask Question