lua-users home
lua-l archive

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


Hi All
I have a string as below.

INVITE\r\n
Content-Length:\r\n
\r\n
v=0\r\n

I want to change it to as below

INVITE\r\n
Content-Length: 3\r\n
\r\n
v=0\r\n

You can see in line starts with Content-Length, I have added 5 at the end because after empty line I have only 5 characters (that is v=0\r\n)

I am looking for what is the best way to do that.
The line Content-Length:\r\n can be of any form given below
a) Content-Length     :\r\n
b) Content-Length:    \r\n
c) Content-Length     :      \r\n

So you can any number of spaces can come anywhere around char : present in line

Can somebody kindly help what is the best way to do it in Lua 5.2

Many thanks
Austin