lua-users home
lua-l archive

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


It was thus said that the Great Dirk Laurie once stated:
> 
> The implementation described in my post is indeed trivial.
> 
> > line="the quick brown fox jumps over the lazy dog"
> > for word in line:gmatch"(%w+)%s+" do print(word) end
> the
> quick
> brown
> fox
> jumps
> over
> the
> lazy
> > for word in line:gmatch"(%w+)%s>" do print(word) end
> the
> quick
> brown
> fox
> jumps
> over
> the
> lazy
> dog

  But this also works:

> for word in line:gmatch"(%w+)%s*" do print(word) end
the
quick
brown
fox
jumps
over
the
lazy
dog

  No need for a patch unless you *want* a space or an end-of-line (or
string) at the end of each word.  If you want that, them I might suggest
LPeg for your parsing needs.

  -spc