0

I'm looking for a batch file to locate text that comes between a static left & right boundary.

The text found would be echoed to a new file. The beginning boundary, like the end, are tags (the left curly is really just an opening tag):

{DomainName>some-domain.com{/DomainName>

So what I'm looking to do is have some-domain.com written to a separate file. There is quite a bit more coding on the page both above and below, but the left & right boundaries are always the same.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

1 Answers1

0
@echo off
Setlocal EnableDelayedExpansion
Set "left={DomainName>"
Set "right={/DomainName>"
Set "text={DomainName>some-domain.com{/DomainName>"
Rem Change left delimiter
Set "text=!text:%left%= {"
Rem Change right delimiter
Set "text=!text:%right%=}"
Rem echo text found
For /F "tokens=2 delims={}" %%a in ("!text!") Do echo %%a
Aacini
  • 65,180
  • 12
  • 72
  • 108