On Tue, Mar 27, 2007 at 07:29:08PM -0400, Doug Anderson wrote:
> 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.

> 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.

Your sample may have been line-wrapped, so it's not completely clear where
the line breaks are supposed to be.

Anyway, it looks like there are exactly two instances of $...[CD] for each
account, and you want the second instance.  So something like this should
work:

^ *(\d{4}-\d{5}).*\r(?s:.*?)\$([0-9,]+\.\d\d[CD])$

The (?s:.*?) is the key part.  (?s) means allow . to match newlines.  .*?
is like .*, except that it matches as few characters as it can, rather than
as many as it can.

HTH,
Ronald

-- 
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to