lua-users home
lua-l archive

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


Hi Enrico Colombini
Your suggestion worked fine. Thanks.

The final function looks as

function calculate_content_length(msg, length)
    local lens = msg:match('Content%-Length%s*:%s+(%d+)%s+')
    local len = 0
    if lens then -- gotcha Content-length
       len = tonumber(lens)
    end
    return len
end

Thanks
Austin




On Mon, Jul 7, 2014 at 2:47 PM, Enrico Colombini <erix@erix.it> wrote:
On 07/07/2014 10.33, steve donovan wrote:
local lens = input:match('^Content%-Length%s*:%s+(%d+)%s+$')

I think it should not be anchored: he said "input string might have some data before or after of given example values".

To Austin: try removing the leading '^' and the trailing '$' from the pattern string.

--
  Enrico