[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Patterns: Why are anchors not character classes?
- From: Sean Conner <sean@...>
- Date: Sat, 18 Jul 2015 16:12:44 -0400
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