[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Patterns: Why are anchors not character classes?
- From: Parke <parke.nexus@...>
- Date: Tue, 14 Jul 2015 09:31:49 -0700
On Tue, Jul 14, 2015 at 9:21 AM, John Hind <email@example.com> wrote:
> I've just had another bout of wrestling with patterns, probably the most
> obscurantist part of Lua and the only bit I've never been able to learn and
> always have to get "Programming in Lua" off the shelf. Take the simple case
> of parsing a comma-separated list, the kludge I keep coming back to is
> concatenating a terminating comma onto the source string before applying the
> ps = "1,22,33,4444"
> ps = ps .. ","
> for n in ps:gmatch("(%d+),") do
for s in ('1,22,33,4444') : gmatch '%d+' do print ( s ) end
for s, c in ('1,22,33,4444') : gmatch '(%d+)(,?)' do print ( s, c ) end
If you need more than either of the above, have you tried LPeg?