lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hey gang,

I'm not seeing an obvious 'doh!' type solution. Here is my question:

Let's say I have a bunch of data output files and I want to merge the last line from each into another table. For simplicity sake, let's say that the
table looks like this:

1 2 3
4 5 6
7 8 9

and I've read that into a string called str.

How do I get the 7 8 9 gracefully? I could read it into a table and just grab the last line, but I would prefer to do it in one fell swoop, as I'm dealing with data files that have many lines to each run.

I've tried the following:

_,_,last = string.find(str,'([^\n]*)')

which produces the expected result
1 2 3

I try anchoring it with the following

_,_,last = string.find(str,'(^\n]*$)')

which produces
nil

Am I misunderstanding how the '$' anchor works? It seems like it should be brain-dead easy to do this (proving that I am past brain-dead at the moment).

Thanks for any insight!

yrs,
Keith
--
Keith Pimmel     ~~~~     Dynetics, Inc.     ~~~~     256.964.4717