[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Patterns: Why are anchors not character classes?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 14 Jul 2015 22:13:15 +0200
2015-07-14 18:21 GMT+02:00 John Hind <firstname.lastname@example.org>:
> 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.
Oh, I just use the online manual and pick the last string function in
the index. The patterns come immediately after. I can't remember
all of them either. :-)
> Take the simple case of parsing a comma-separated list
That's [^,]+ or [^,]* depending on whether empties are allowed.
> If the start and end anchors behaved like character classes we could do
> better. For regularity they probably should be %^ and %$
An interesting notion. I'll probably use it.
> The other thing I'd like to see is some "standard" patterns as constants in
> the string library for the common functions that a C programmer for example
> will miss ("trimright", "trimleft" and "trim", for example).
Well, now. A little module that monkeypatches those into the string library
is surely not too hard?