lua-users home
lua-l archive

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


On Mon, Jul 7, 2014 at 9:18 AM, Austin Einter <austin.einter@gmail.com> wrote:
> Please note that, input string might have some data before or after of given
> example values.

How about something really simple?

local lens = input:match('^Content%-Length%s*:%s+(%d+)%s+$')
if lens then -- gotcha Content-length
   len = tonumber(lens)
end

Note how '-' must be escaped...%s matches all whitespace, including line ends.