Substract string in brackets

December 15, 2009 at 09:39:04
Specs: Windows XP
Hi, I'm writing universal updater for my company and don't know how to extract uninstall GUID from such string:

{3DC4EB93-A8EE-45D1-8C35-B3FCC3076EA6}: EZVideoServer (version 3.3.4)

It is a batch file - I've read many post found by google but still have problem.

I need to extract string in brackets including brackets {}:
Output string should be:
{3DC4EB93-A8EE-45D1-8C35-B3FCC3076EA6}


See More: Substract string in brackets

Report •


#1
December 15, 2009 at 16:15:26
set your delim as "}", set tokens for 1,*, then use a for loop, get the 1st token.

alternatively, get a good text/string parser, such as gawk.exe (see my sig)

C:\test>echo {3DC4EB93-A8EE-45D1-8C35-B3FCC3076EA6}: EZVideoServer (version 3.3.4) |gawk -F"[{}]" "{print $2}"
3DC4EB93-A8EE-45D1-8C35-B3FCC3076EA6

GNU win32 packages | Gawk


Report •

#2
December 16, 2009 at 05:01:32
@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=1 delims=:" %%a in (mystring.txt) do (
> newfile echo %%a
)


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

M2


Report •

#3
December 16, 2009 at 14:27:09
I don't know how but it works.
Thank You :)

Report •

Related Solutions

#4
December 16, 2009 at 15:18:10
As we used to say in tech school, it works quickly, silently & electronically.


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

M2


Report •

#5
December 17, 2009 at 08:27:21
Gori, it's simple, we're lucky that the syntax is easy to read, and that the text string you are after, is nicely separated by the colon character ... and we just tell it to take the first column, if you consider the colon to be a separator (delimitor)

Report •


Ask Question