computing
  • 0

Solved Extract By a Batch File, The Lines Located Between Two Tags

  • 0

I need to pick up by a batch file, the lines located between two tags within a text file. For example:

my file.txt:

E024=ER

R024= 1.0BX/FT
TRAJET-
1 PR 5024 OP16MAR 6 LPD PLY BI1 22:30 06:30 17MAR 7 AL
SAC
BUREAUX EFFECTIFS –
1.ETAGE/A1 15MAR ETC 17MAR FRPLY
DATE LIMITE D’ECHANGE –
1.T- 29JAN 11:27 INDIVIDUEL
TK 471144962 DE
TELEPHONE –
1. NC
RECU DE-TE
C-TBH
PNO.HDQ4D 1127/29JAN13 QYOXPL H

E025=I

end file.

I want to extract all lines between the specific strings “E024” and “E025”, except them. Please how can i do that? Now I only got one line. Thank you in advance

Share

1 Answer

  1. Ok, here’s what I could come up with:
    ‘===== begin vbscript anomyze.vbs, usage: anomyze infile > outfile
    set regex=new regexp
    regex.ignorecase=false
    regex.global=true
    set fso=createobject(“scripting.filesystemobject”)
    z=fso.opentextfile(wscript.arguments(0),1).readall
    dim n(6)
    ‘== first, the base
    n(0)=”\d{1,2}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)”
    ‘now add qualifiers
    n(1)=n(0)+”13″
    n(2)=n(0)+”\b”
    n(0)=n(0)+”13 [A-Z]{6} “
    n(3)=”——- —— “
    n(4)=”*******”
    n(5)=”*****”
    for i=0 to 2
    regex.pattern=n(i)
    z=regex.replace(z,n(i+3))
    next
    wscript.echo z
    ‘====== end vbscript

    You will note that the year is “hard-wired” as 13. You could make it more flexible, if need be: replace “13 [” with “1\d{1,1} [“

    • 0