I've got a text file that lists accounting activity in GL accounts. I'm
wanting to pull the account number, then the ending balance from this file.
Problem is the account number is on one line, then there are one or more
lines after the acct# line before you get to the ending balance.
Here is one segment from the file as an example.
0102-72000 SALARIES & WAGES $527,056.11D
08/31/05 GLSUM
A/P 178570.60
08/31/05 RV003 AUG ACCRUED
SALARIES 500.00
08/31/05 RV004 AUG ACCRUED
COMMISSIONS 34463.00
08/01/05 RV003 JUL ACCRUED
SALARIES 500.00
08/01/05 RV004 JUL ACCRUED
COMMISSIONS 25000.00
08/01/05 RV004 JUL REVERSE
RV070506 129780.00
08/01/05 RV006 JUL OTC EXECUTION
WAGES 129780.00
------------- -------------
343313.60 155280.00 $715,089.71D
Total
Activity =============
=============
343313.60 155280.00
0102-72430 401(k) MATCH $12,060.74D
08/31/05 GLSUM
A/P 301.32
------------- -------------
301.32 .00 $12,362.06D
Total
Activity =============
=============
301.32 .00
The first part is easy, this search string would find the account number,
^ (\d{4}-\d{5}).*\r
and would assign the account number to \1 for use in my replace.
The last part is also easy,
^.*\$([0-9,]+\.\d\d[CD])$
and would assign the ending balance to \2 also for use in my replace.
My problem arises from what I should use to pick up everything in between so
that my search will find the acct# and ending balance in one fell swoop.
Any suggestions would be welcome. If it were always a fixed number of lines
I think I could handle it, problem is, for one account there may be three
lines between the acct# line and the ending balance line and for another
there may just be one line between the two.