[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Simple pattern matching...
- From: Mike McGonagle <mjmogo@...>
- Date: Thu, 16 Dec 2010 15:14:04 -0500
Hello All,
I guess I just don't understand why this does not work, but I have a
simple text file where each line has three chunks of data, separated
by tabs. I am using the following code to split them, but match does
not seem to return the last chunk...
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
(obviously here the tabs were converted to spaces by the email program)
But I get the error of "bad argument #4 to 'format' (string expected,
got no value)", and the variable 'slider' is 'nil'.
Thanks,