lua-users home
lua-l archive

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


>> But I wonder why "*w" is dropped (in the source too). It can't be
>> replaced by "*u" because the isspace function can be true for several
>> different characters (space, tab, newline, etc.).
>You are right, it can't. The "*w" was dropped because it was quite
>arbitrary in its definition of "word", and more often than not that
>definition was not what we wanted. But we can put it back, if many people
>miss it.

Perhaps it would be a better solution to allow more complex arguments to
"*u"?
ideal would be to have the same power as for strfind:
then we could write "*w" as "*u%s+" (or "*[^%d]+" for extracting numbers out
of a file etc.)
if you like this idea, you could go one step further and add another format
"*p" that reads the next matching pattern, then we can write "*w" as "*u%w+"

of course we can still read the file as a whole (provided it is not too
large) and then use the power of gsub:

s = read("*a")
gsub(s, "([^%s]+)", function(word)
	print(word) -- or do whatever
)

just my 2 cents

Peter Prade