lua-users home
lua-l archive

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


On Thu, 2010-12-16 at 15:14 -0500, Mike McGonagle wrote:
> for line in io.lines(filename) do
>   name, register, sliders = line:match("([%S]*)[%s]*([%S]*)[%s]*([%S]*)")
>   print(string.format("name = '%s' register = '%s' sliders = '%s'",
> name, register, slider))
> end
> 
> with the input line of:
> 
> Saxophone                       8       018763431

For me your example works OK:

$ lua
> line = "Saxophone\t8\t018763431"
> name, register, sliders = line:match("([%S]*)[%s]*([%S]*)[%s]*([%
S]*)")
> print(name, register, sliders)
Saxophone	8	018763431
 
> But I get the error of "bad argument #4 to 'format' (string expected,
> got no value)", and the variable 'slider' is 'nil'.

Try using print() instead, it works OK with nils