[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Finding intermediate token in a string
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 7 Jul 2014 11:46:55 +0200
2014-07-07 9:18 GMT+02:00 Austin Einter <austin.einter@gmail.com>:
> Hi All
> I can have an input string with any one of below formats
>
> \r\nContent-Length: 100 \r\n
> \r\nContent-Length : 100 \r\n
> \r\nContent-Length:100 \r\n
>
> Input string can be of any one value from above examples
>
> My aim is to extract 100 as an integer.
>
> What is the best way to do it.
>
> Please note that, input string might have some data before or after of given
> example values.
pat="\r\nContent%-Length:%s*(%d+)%s+\r\n"
num = tonumber(string.match(str,"pat"))