lua-users home
lua-l archive

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

The ambiguity if it should search "plainly" or do a pattern match has
always tripped me up in the differences between string.sub() and
string.gsub()  I keep trying thinking about how string.match() and
string.gmatch() work, and then I fumble when I remember that
string.sub() has nothing to do with patterns.  I wish all these
functions were named a little more clearly.... If anyone knows what
the g stands for, I would appreciate the explanation. >.<

Anyway, getting back to the point, if a string.split() were created,
it seems to make more sense for it to match a pattern by default. :>
At least in my opinion... but maybe string.split() and string.gsplit()
is necessary.  WHAT IS THIS G?!  Wish it were all just string.slice()
(a slice of the string being the substring), string.sub() for actual
substitutions, string.match(), string.imatch() (for iterator?) or
something like that... only one string.split(), I think it'd be less
likely that you would match plainly...  My thoughts are beyond the
scope of this post, but it seems like clearer function names would be
needed before any other string.*() functions are added to avoid more
confusion :(

On Tue, Dec 29, 2009 at 6:41 AM, David Manura <> wrote:
> On Tue, Dec 29, 2009 at 5:39 AM, steve donovan wrote:
>> On Tue, Dec 29, 2009 at 10:04 AM, steve donovan wrote:
>>> Lua is unique in that all string searching/substitution functions use
>>> patterns, not literals.
> Some concerns about that: