lua-users home
lua-l archive

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


Hi,

I have a feature request for Lua: please add an additional plain
option to gsub which defaults to false. If it is true, it should make
gsub behave like replace() in JavaScript (replace without any pattern
matching).

Why? Because apparently, to emulate this behavior with gsub right now
with arbitrary input strings, one needs to do pattern escape monsters
like in the second response here:
http://stackoverflow.com/questions/1745448/lua-plain-string-gsub

For something like a basic replace() function without patterns (those
obviously can't be used on user-provided strings without escaping
hassle), the provided built-in solution should be better.

Alternatively, I'm also happy for easier solutions to get this
behavior of gsub if this is already possible in an easier way that I
haven't seen.

Regards,
Jonas Thiem