Batch example:
gh0std0g74's scheme for stepping back the strings to store the previous 3 lines read from source file acknowledged.
FOR line written thus to avoid (documented, apparently) problem of for /f skipping blank lines
[Details in alt.msdos.batch.nt thread headed "Bug in For /F" (long Google Groups link shortened)]:
http://tinyurl.com/cwr484I wondered why the line numbers in my output didn't match those from gh0std0g74's VBscript, but then I noticed that my batch was skipping blank lines in the input file. They match now.
@echo off
setlocal enabledelayedexpansion
set string3=
set string2=
set string1=
set i=0
set f=0
set patt3={ACAD_REACTORS
set patt2=330
set patt1=C
set patt0=102
set inputfile=dwg.txt
for /f "tokens=1* delims=]" %%a in ('find /n /v "" ^<%inputfile%') do (
set /a i+=1
set string0=%%b
if "!string0!"=="%patt0%" (
set seq=1
if "!string3!"=="%patt3%" set /a seq+=1
if "!string2!"=="%patt2%" set /a seq+=1
if "!string1!"=="%patt1%" set /a seq+=1
)
if !seq! equ 4 (
set /a f+=1
echo !string3!
echo !string2!
echo !string1!
echo !string0! [Line !i!] [!f!]
echo --------------------------
set seq=0
)
set string3=!string2!
set string2=!string1!
set string1=!string0!
)