This can be simplified a lot with the following observations.
  1. The id is the first word after the [.
  2. The program is the second word after the third quote.
Here is the script. It does not require the file be reformatted in any special way.
# Script parse.txt
# Input argument - path of input file.
var str path

# Read input into a variable.
var str input ; cat $path > $input

# Keep going until there is a next record.
while ( { sen "^[^" $input } > 0 )
do
    # Discard portion up to (and including) the next [.
    stex "^^" $input > null

    # The next word is the id.
    var str id ; wex "1" $input > $id

    # Discard portion up to (and including) the third (3) quote.
    stex "^,^]" $input > null

    # The second word is the program.
    var str program ; wex "2" $input > $program

    # Show the extracted id and program.
    echo $id "\t" $program
done
This script will do it. It is in biterscripting ( http://www.biterscripting.com ) Save the script as C:\Scripts\parse.txt. Start biterscripting. Assuming your input file is at C:\input.log, call the script by entering the following command.
script parse.txt path("C:\input.log")
Let me know if this works for you.

Jenni


In reply to Re: Parsing log file with biterscripting by JenniC
in thread Basic regex to parse source code by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.