[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: extension to string.gmatch (structural regular expressions)
- From: Miles Bader <miles@...>
- Date: Thu, 03 Jan 2008 10:41:00 +0900
Ben <email@example.com> writes:
> On Jan 2, 2008 12:41 PM, Duck <firstname.lastname@example.org> wrote:
>> Isn't this the sort of string library function which many languages offer
>> under a name such as "split"? Break a string into fields separated by some
>> (possibly non-trivial) pattern (default usually something like '[ \t]*')?
> Yeah, that's one thing of two bigs things I miss in Lua coming from
> Python, list comprehensions and the str.split method.
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 ...
The key to happiness
is having dreams. [from a fortune cookie]