lua-users home
lua-l archive

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


Miles Bader wrote:

Though in many cases, you don't really need split, e.g. something like
the following is actually cleaner than doing a split and iterating over
the resulting table:

   for field in string.gmatch (STRING, "[^ \t\n]+") do
     .... use field ...
   end

And what if the fields are delimited by, say, "<delim>" ?

The rule of thumb is to use gmatch when fields are easier to express with regexp than delimiters, otherwise use split (provided it's available :) ).

--
Shmuel