Batch file regexp

April 14, 2009 at 11:38:23
Specs: Windows XP

I'm trying to extract a sting (e.g. 117.BSI.M.U2.N.A.A20.I.1.U2.2240.Z01.E) from a html file I've downloaded with curl in a batch script.

In my example I'm trying to find:

in e.g.

(here %ecbKey% = BSI.M.U2.N.A.A20.I.1.U2.2240.Z01.E)

The best I can come up with is:
curl -s -d "type=serieskey&q=%ecbKey%" -o temp.txt
for /f "usebackq tokens=4 delims==" %%g in (`findstr /r "[0-9][0-9][0-9].%ecbKey%" temp.txt`) do echo %%g

However, this returns ""117.BSI.M.U2.N.A.A20.I.1.U2.2240.Z01.E" />" instead of '117.BSI.M.U2.N.A.A20.I.1.U2.2240.Z01.E'

Any suggestions would be highly appreciated.

See More: Batch file regexp

Report •

April 14, 2009 at 18:29:43
i see you can use curl, therefore i assume you can download tools. (see my sig)
C:\test>set a=BSI.M.U2.N.A.A20.I.1.U2.2240.Z01.E
C:\test>grep -o [0-9][0-9][0-9].%a% temp.txt

C:\test>grep -o [0-9][0-9][0-9].%a% file.txt|head -1

Unix Win32 tools | Gawk for Windows

Report •

April 15, 2009 at 01:27:19
Thanks, that's very helpful

Report •

Related Solutions

Ask Question