[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: lex parsing floating point values
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 28 May 2003 19:47:15 -0300
Mike Spencer wrote:
>but i would also like to know how to parse floating point using lex
The code below will split the line into the fields you want.
To test whether the value is a valid number, use tonumber.
while true do
local line=io.read()
if line==nil then break end
local ok,_,name,value=string.find(line,"%s*(%S+)%s*=%s*(%S+)%s*")
if ok then print(name,value) else error("bad line: "..line) end
end
--lhf