lua-users home
lua-l archive

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


On Jan 23, 2008 10:53 AM, Eric Tetz <erictetz@gmail.com> wrote:
   local pages = {}
   for page in data:gmatch('[^\f]*\f+') do

     pages[ #pages + 1 ] = page
   end

If you want to capture only the text (discarding the form feeds), change the _expression_ to '([^\f]*)\f+', which will 'capture' the part you want.
 
Oops. Was reading PiL today, and it dawned on me that this pattern is naive. If we're using gmatch, we don't need a capture to skip the unwanted form feeds -- the pattern need only include the characters we *want*.

    for page in data:gmatch('[^\f]+') do ...

Cheers,
Eric