lua-users home
lua-l archive

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


1. Regarding match/gmatch:

Tbh I think match/gmatch are more obvious functions of the regex
realm, I am not aware of any "plain" functions that do similar things
in other languages.

However, :gsub has the very common .replace() counterpart (e.g.
compare JS), and find obviousy also has obvious non-regex counterparts
in other languages. And those are also the two where I commonly need
to use non-regex versions personally. I wouldn't have much of a need
for match/gmatch.

As for consistency, this seems like a very good question. But I'm not
sure what to suggest for match/gmatch.

2. Regarding magic character/"rest of string as plain":

Yes, such a "plain from now on" character might help - but since find
already has a plain option, a more obvious consistant change would be
to add that option to gsub too - or alternatively, introduce a new
string.replace which behaves like in other languages without pattern
matching for regular string inputs.


On Thu, Aug 21, 2014 at 4:59 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-08-21 16:23 GMT+02:00 Jonas Thiem <jonasthiem@googlemail.com>:
>
>> Hm I see. Still, wouldn't a plain option be more consistent with find
>> and easier to use for beginners?
>
> Then what about `match` and `gmatch`? You want a plain option
> added to some but not all four pattern-aware string routines?
>
> Would a magic character that says: "ignore me, and treat the
> rest of the string as plain" solve your problem? For example,
> closing bracket or parenthesis.
>